Concatenate two primes is also prime: Difference between revisions

Added 11l
(Concatenate two primes is also prime en BASIC256)
(Added 11l)
Line 4:
Find and show here when the concatenation of two primes &nbsp; ('''p<sub>1</sub>''', &nbsp;'''p<sub>2</sub>''') &nbsp; shown in base ten is also prime, &nbsp; where &nbsp; '''p<sub>1</sub>, &nbsp; p<sub>2</sub> &nbsp;&lt;&nbsp; 100'''.
<br><br>
 
=={{header|11l}}==
{{trans|Nim}}
 
<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
 
V primes = (2..99).filter(n -> is_prime(n))
 
Set[Int] concatPrimes
L(p1) primes
L(p2) primes
V n = p2 + p1 * (I p2 < 10 {10} E 100)
I is_prime(n)
concatPrimes.add(n)
 
print(‘Found ’concatPrimes.len‘ primes which are a concatenation of two primes below 100:’)
L(n) sorted(Array(concatPrimes))
print(‘#4’.format(n), end' I (L.index + 1) % 16 == 0 {"\n"} E ‘ ’)</lang>
 
{{out}}
<pre>
Found 128 primes which are a concatenation of two primes below 100:
23 37 53 73 113 137 173 193 197 211 223 229 233 241 271 283
293 311 313 317 331 337 347 353 359 367 373 379 383 389 397 433
523 541 547 571 593 613 617 673 677 719 733 743 761 773 797 977
1117 1123 1129 1153 1171 1319 1361 1367 1373 1723 1741 1747 1753 1759 1783 1789
1913 1931 1973 1979 1997 2311 2341 2347 2371 2383 2389 2917 2953 2971 3119 3137
3167 3719 3761 3767 3779 3797 4111 4129 4153 4159 4337 4373 4397 4723 4729 4759
4783 4789 5323 5347 5923 5953 6113 6131 6143 6173 6197 6719 6737 6761 6779 7129
7159 7331 7919 7937 8311 8317 8329 8353 8389 8923 8929 8941 8971 9719 9743 9767
</pre>
 
=={{header|Action!}}==
1,480

edits