Magnanimous numbers: Difference between revisions

Add Draco
(add BCPL)
(Add Draco)
Line 889:
559952 595592 595598 600881 602081
</pre>
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc isprime(word n) bool:
word d;
bool prime;
if n<2 then false
elif n%2=0 then n=2
elif n%3=0 then n=3
else
prime := true;
d := 5;
while prime and d*d <= n do
if n%d=0 then prime := false fi;
d := d+2;
if n%d=0 then prime := false fi;
d := d+4
od;
prime
fi
corp
 
proc magnanimous(word n) bool:
word left, right, shift;
bool magn;
left := n;
right := 0;
shift := 1;
magn := true;
while magn and left >= 10 do
right := right + (left % 10) * shift;
shift := shift * 10;
left := left / 10;
magn := magn and isprime(left + right)
od;
magn
corp
 
proc main() void:
word n, i;
n := 0;
for i from 1 upto 250 do
while not magnanimous(n) do n := n+1 od;
if i=1 then writeln("1 - 45:") fi;
if i=241 then writeln("241 - 250:") fi;
if i<=45 or i>=241 then
write(n:7);
if i%5 = 0 then writeln() fi
fi;
n := n+1
od
corp</syntaxhighlight>
{{out}}
<pre>1 - 45:
0 1 2 3 4
5 6 7 8 9
11 12 14 16 20
21 23 25 29 30
32 34 38 41 43
47 49 50 52 56
58 61 65 67 70
74 76 83 85 89
92 94 98 101 110
241 - 250:
17992 19972 20209 20261 20861
22061 22201 22801 22885 24407</pre>
 
=={{header|F_Sharp|F#}}==
Line 929 ⟶ 994:
486685 488489 515116 533176 551558 559952 595592 595598 600881 602081
</pre>
 
=={{header|Factor}}==
{{trans|Julia}}
2,115

edits