Jump to content

Deceptive numbers: Difference between revisions

(Prolog version)
Line 682:
<pre>91 259 451 481 703 1729 2821 2981 3367 4141 4187 5461 6533 6541 6601 7471 7777 8149 8401 8911 10001 11111 12403 13981 14701</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'prime'
 
deceptives = Enumerator.new do |y|
10.step(by: 10) do |n|
[1,3,7,9].each do |digit|
cand = n + digit
next if cand % 3 == 0 || cand.prime?
repunit = ("1"*(cand-1)).to_i
y << cand if (repunit % cand) == 0
end
end
end
 
p deceptives.take(25).to_a
</syntaxhighlight>
{{out}}
<pre>[91, 259, 451, 481, 703, 1729, 2821, 2981, 3367, 4141, 4187, 5461, 6533, 6541, 6601, 7471, 7777, 8149, 8401, 8911, 10001, 11111, 12403, 13981, 14701]
</pre>
=={{header|Rust}}==
<syntaxhighlight lang="rust">// [dependencies]
1,149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.