A happy numeric coincidence
blog.plover.com
blog.plover.com
http://recursed.blogspot.com/2007/09/mathematics-in-jack-rea... Base 10: https://oeis.org/A023106 Base 2: https://oeis.org/A256590
> Extra credit: explain why nobody cares.
Also, why limit this to base 10? Anything with base 10 digits is not the purest possible math imho because it depends on the arbitrary value 10 while you could generalize to any other value.
2222 ^ 145
log(x^y)*4.5 = x
y*log(x)*4.5 = x
y = x/(4.5*log x)
So picking a random number like 234, we get y=21.94819 and the digit sum of 234^22 == 234. In this case we actually just had to compute one exponent and one digit sum.That this pattern didn’t swamp the results makes me wonder what kind of bug the author has in the scanning code.
[edit: seems I forgot about situations like 9 x 11 x N, where the digits can add up to 18, 27, etc due to all the 8 and 9 digits, so the algorithm will only find multiples of 9 with lots of small digits in it.]
Similarly, in base 8 7^2 is 61 and in hex f^2 is e1.
(n-1)^2 = n^2 - 2*n + 1 = n(n-2) + 1 which in base n is written with n-2 as the fist digit and 1 as the second digit.
You might add the digits up to 36, whose digits then add up to 9. Simply reapply to the sum if the sum has more than 1 digit, and you'll still arrive at 9.
digitalsum(999^75) = 999
999^75 = 927708673390001466432161699937587612771693772928727827334425528520027513591277141564708297244305734237029149442895264407211992619276548532187236223108524403378301874096420069132958960388059297398105903507708174617522225074999 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 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 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.)Nerdy enough (and well written enough) that I'll add this blog to my RSS reader. 2019 is off to a good start!