Magnanimous numbers: Difference between revisions
Content added Content deleted
(Added GW-BASIC) |
(Added Easylang) |
||
Line 954: | Line 954: | ||
17992 19972 20209 20261 20861 |
17992 19972 20209 20261 20861 |
||
22061 22201 22801 22885 24407</pre> |
22061 22201 22801 22885 24407</pre> |
||
=={{header|EasyLang}}== |
|||
{{trans|AWK}} |
|||
<syntaxhighlight> |
|||
fastfunc isprim num . |
|||
if num < 2 |
|||
return 0 |
|||
. |
|||
i = 2 |
|||
while i <= sqrt num |
|||
if num mod i = 0 |
|||
return 0 |
|||
. |
|||
i += 1 |
|||
. |
|||
return 1 |
|||
. |
|||
func ismagnan n . |
|||
if n < 10 |
|||
return 1 |
|||
. |
|||
p = 10 |
|||
repeat |
|||
q = n div p |
|||
r = n mod p |
|||
if isprim (q + r) = 0 |
|||
return 0 |
|||
. |
|||
until q < 10 |
|||
p *= 10 |
|||
. |
|||
return 1 |
|||
. |
|||
proc magnan start stop . . |
|||
write start & "-" & stop & ":" |
|||
while count < stop |
|||
if ismagnan i = 1 |
|||
count += 1 |
|||
if count >= start |
|||
write " " & i |
|||
. |
|||
. |
|||
i += 1 |
|||
. |
|||
print "" |
|||
. |
|||
magnan 1 45 |
|||
magnan 241 250 |
|||
magnan 391 400 |
|||
</syntaxhighlight> |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |