Prime numbers which contain 123: Difference between revisions
Content added Content deleted
No edit summary |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 8: | Line 8: | ||
As above, but only show the <u>count</u> of those primes '''n''' that contain the (above) string, where '''n < 1,000,000'''. |
As above, but only show the <u>count</u> of those primes '''n''' that contain the (above) string, where '''n < 1,000,000'''. |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
<lang 11l>F is_prime(a) |
|||
I a == 2 |
|||
R 1B |
|||
I a < 2 | a % 2 == 0 |
|||
R 0B |
|||
L(i) (3 .. Int(sqrt(a))).step(2) |
|||
I a % i == 0 |
|||
R 0B |
|||
R 1B |
|||
F is_prime123(n) |
|||
R ‘123’ C String(n) & is_prime(n) |
|||
V c = 0 |
|||
L(n) 100'000 |
|||
I is_prime123(n) |
|||
c++ |
|||
print(‘#5’.format(n), end' I c % 8 == 0 {"\n"} E ‘ ’) |
|||
print() |
|||
print(‘Found ’c‘ "123" primes less than 100000’) |
|||
c = 0 |
|||
L(n) 1'000'000 |
|||
I is_prime123(n) |
|||
c++ |
|||
print() |
|||
print(‘Found ’c‘ "123" primes less than 1000000’)</lang> |
|||
{{out}} |
|||
<pre> |
|||
1123 1231 1237 8123 11239 12301 12323 12329 |
|||
12343 12347 12373 12377 12379 12391 17123 20123 |
|||
22123 28123 29123 31123 31231 31237 34123 37123 |
|||
40123 41231 41233 44123 47123 49123 50123 51239 |
|||
56123 59123 61231 64123 65123 70123 71233 71237 |
|||
76123 81233 81239 89123 91237 98123 |
|||
Found 46 "123" primes less than 100000 |
|||
Found 451 "123" primes less than 1000000 |
|||
</pre> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |