De Polignac numbers: Difference between revisions

Added 11l
(Added 11l)
Line 27:
;* [[oeis:A006285|OEIS:A006285 - Odd numbers not of form p + 2^k (de Polignac numbers)]]
 
 
=={{header|11l}}==
{{trans|C++}}
 
<syntaxhighlight lang="11l">
F is_prime(p)
I p < 2 | p % 2 == 0
R p == 2
L(i) (3 .. Int(sqrt(p))).step(2)
I p % i == 0
R 0B
R 1B
 
F is_depolignac_number(n)
V p = 1
L p < n
I is_prime(n - p)
R 0B
p <<= 1
R 1B
 
print(‘First 50 de Polignac numbers:’)
V count = 0
L(n) (1..).step(2)
I is_depolignac_number(n)
count++
I count <= 50
print(f:‘{commatize(n):5}’, end' I count % 10 == 0 {"\n"} E ‘ ’)
E I count == 1000
print("\nOne thousandth: "commatize(n))
E I count == 10000
print("\nTen thousandth: "commatize(n))
L.break
</syntaxhighlight>
 
{{out}}
<pre>
First 50 de Polignac numbers:
1 127 149 251 331 337 373 509 599 701
757 809 877 905 907 959 977 997 1,019 1,087
1,199 1,207 1,211 1,243 1,259 1,271 1,477 1,529 1,541 1,549
1,589 1,597 1,619 1,649 1,657 1,719 1,759 1,777 1,783 1,807
1,829 1,859 1,867 1,927 1,969 1,973 1,985 2,171 2,203 2,213
 
One thousandth: 31,941
 
Ten thousandth: 273,421
</pre>
 
=={{header|Action!}}==
1,481

edits