Descending primes: Difference between revisions

Content added Content deleted
(Added Quackery.)
(Added 11l)
Line 8: Line 8:
*[[Ascending primes]]
*[[Ascending primes]]



=={{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

V c = 0
V ps = [1, 2, 3, 4, 5, 6, 7, 8, 9]
V nxt = [0] * 128

L
V nc = 0
L(a) ps
I is_prime(a)
c++
print(‘#8’.format(a), end' I c % 5 == 0 {"\n"} E ‘ ’)
V b = a * 10
V l = a % 10 + b
b++
L b < l
nxt[nc] = b
nc++
b++

I nc > 1
ps = nxt[0 .< nc]
E
L.break

print("\n"c‘ descending primes found’)
</syntaxhighlight>

{{out}}
<pre>
2 3 5 7 31
41 43 53 61 71
73 83 97 421 431
521 541 631 641 643
653 743 751 761 821
853 863 941 953 971
983 5431 6421 6521 7321
7541 7621 7643 8431 8521
8543 8641 8731 8741 8753
8761 9421 9431 9521 9631
9643 9721 9743 9851 9871
75431 76421 76541 76543 86531
87421 87541 87631 87641 87643
94321 96431 97651 98321 98543
98621 98641 98731 764321 865321
876431 975421 986543 987541 987631
8764321 8765321 9754321 9875321 97654321
98764321 98765431
87 descending primes found
</pre>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
Line 71: Line 132:
8764321 8765321 9754321 9875321 97654321 98764321 98765431
8764321 8765321 9754321 9875321 97654321 98764321 98765431
</pre>
</pre>

=={{header|Arturo}}==
=={{header|Arturo}}==
{{trans|ALGOL 68}}
{{trans|ALGOL 68}}