One-two primes: Difference between revisions

m
Line 113:
1111111111111111111
11111111111111212121</syntaxhighlight>
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">""" rosettacode.org/wiki/One-two_primes """
 
using IntegerMathUtils # for the call to libgmp's gmpz_probab_prime_p
 
""" From Chai Wah Wu's Python code at oeis.org/A036229 """
function show_oeis36229(wanted = 2000)
for ndig in vcat(1:20, 100:100:wanted)
k, r, m = (big"10"^ndig - 1) ÷ 9, big"2"^ndig - 1, big"0"
while m <= r
t = k + parse(BigInt, string(m, base = 2))
if is_probably_prime(t)
pstr = string(t)
if ndig < 21
println(lpad(ndig, 4), ": ", pstr)
else
k = something(findfirst(!=('1'), pstr), ndig) - 1
println(lpad(ndig, 4), ": (1 x $k) ", pstr[k:end])
end
break
end
m += 1
end
end
end
 
show_oeis36229()
</syntaxhighlight>{{out}}
<pre>
1: 2
2: 11
3: 211
4: 2111
5: 12211
6: 111121
7: 1111211
8: 11221211
9: 111112121
10: 1111111121
11: 11111121121
12: 111111211111
13: 1111111121221
14: 11111111112221
15: 111111112111121
16: 1111111112122111
17: 11111111111112121
18: 111111111111112111
19: 1111111111111111111
20: 11111111111111212121
100: (1 x 92) 121112211
200: (1 x 192) 121112211
300: (1 x 288) 1211121112221
400: (1 x 390) 12111122121
500: (1 x 488) 1221222111111
600: (1 x 590) 12112222221
700: (1 x 689) 121111111111
800: (1 x 787) 12122222221111
900: (1 x 891) 1222221221
1000: (1 x 988) 1222122111121
1100: (1 x 1087) 12112111121111
1200: (1 x 1191) 1211222211
1300: (1 x 1289) 122121221121
1400: (1 x 1388) 1222211222121
1500: (1 x 1489) 121112121121
1600: (1 x 1587) 12121222122111
1700: (1 x 1688) 1212121211121
1800: (1 x 1791) 1221211121
1900: (1 x 1889) 122212212211
2000: (1 x 1989) 122121121211
</pre>
 
=={{header|Phix}}==
4,107

edits