Curzon numbers: Difference between revisions
→{{header|Ruby}}: Switched to modular pow like Python
(Python: much faster with modpow) |
(→{{header|Ruby}}: Switched to modular pow like Python) |
||
Line 1,356:
<syntaxhighlight lang="ruby">def curzons(k)
Enumerator.new do |y|
(1..).each
m = k * n + 1
y << n if k.pow(n, m ) + 1 == m
end
end
end
[2,4,6,8,10].each do |base|
end</syntaxhighlight>
Line 1,386 ⟶ 1,389:
Thousandth Curzon with k = 10: 46845.
</pre>
=={{header|Rust}}==
<syntaxhighlight lang="rust">fn modpow(mut base: usize, mut exp: usize, n: usize) -> usize {
|