12345678910111213141516171819202122232425262728 |
- #!/usr/bin/ruby
- # Modular computation of the tetration operation, using Euler's theorem.
- # See also:
- # https://en.wikipedia.org/wiki/Tetration
- # https://www.youtube.com/watch?v=vzhzwLp_qrs
- func tetration(a, b, m) {
- return 0 if (m == 1)
- return 1 if (b == 0)
- powmod(a, __FUNC__(a, b-1, m.euler_phi), m)
- }
- for n in (2 .. 1000) {
- var k = n.prime
- if (tetration(10, 10, k) + 23 % k == 0) {
- say "#{'%3s' % k} | (10∆10 + 23)"
- }
- }
- __END__
- 3 | (10∆10 + 23)
- 13 | (10∆10 + 23)
- 673 | (10∆10 + 23)
|