News for hackers. Stuff that matters.
Re:A happy numeric coincidence by sonofgod on Wednesday January 02, 2019 @11:06AM (#18807077)
I'm getting bigger numbers from a very quick script -- am I missing something?

digitalsum(999^75) = 999

  999^75 = 927708673390001466432161699937587612771693772928727827334425528520027513591277141564708297244305734237029149442895264407211992619276548532187236223108524403378301874096420069132958960388059297398105903507708174617522225074999
Re:A happy numeric coincidence by sonofgod on Wednesday January 02, 2019 @11:07AM (#18807089)

  def test(x, y, debug=True):
      num = x**y
      digitalsum = sum(int(a) for a in str(num))
      if x == digitalsum and debug:
          print x, y, num
      return x == digitalsum
  
  for i in range(1,1000):
      for j in range(1,100):
          if test(i, j):
              print i, j
Re:A happy numeric coincidence by lmcarreiro on Wednesday January 02, 2019 @11:13AM (#18807155)
After you calc X^Y, when you will calc X^(Y+1), doesn't it worth to calc using the previous result (X^Y)*X instead of another power X^(Y+1) ?
Re:A happy numeric coincidence by kazinator on Wednesday January 02, 2019 @06:43PM (#18811471)
You will find here that the run-time is swamped by the digit breakdown and summing, so that exponentiation versus accumulated product doesn't make a palpable difference.
Re:A happy numeric coincidence by kazinator on Wednesday January 02, 2019 @05:57PM (#18811162)
TXR lisp:

  This is the TXR Lisp interactive listener of TXR 203.
  Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
  1> (each ((x (range 2 1000))) ;; 1 is uninteresting
       (each ((y (range 1 100)))
         (let ((z (expt x y)))
           (when (= x (sum (digits z)))
             (put-line `@x @y`)))))
  2 1
  3 1
  4 1
  5 1
  [...]                                                                
  963 69
  964 75
  964 78
  991 71
  999 75
Re:A happy numeric coincidence by kazinator on Wednesday January 02, 2019 @06:16PM (#18811289)
Using successive multiplication instead of exponent operation:

  6> (each ((x (range 2 1000)))
       (each ((y (range 1 100)) ;; needed just for the put-line
              (z [giterate true (op * x) x]))
         (when (= x (sum (digits z)))
           (put-line `@x @y`))))
(Makes no difference; run time is vastly dominated by the contribution of the (sum (digits z)) business.)