3 ms·
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 1
by kazinator 8y ago
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
- kazinator 8y agoUsing 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.)