Magnanimous numbers: Difference between revisions

m
(Added Easylang)
m (→‎{{header|Wren}}: Minor tidy)
 
(5 intermediate revisions by 2 users not shown)
Line 240:
486685 488489 515116 533176 551558 559952 595592 595598 600881 602081
Last magnanimous number found: 434 = 999994
</pre>
 
 
=={{header|Amazing Hopper}}==
<syntaxhighlight lang="c">
#include <basico.h>
 
#proto encontrarunMagnanimouspara(_X_)
#synon _encontrarunMagnanimouspara siencontréunMagnanimousen
 
algoritmo
 
decimales '0'
res={}, i=0
iterar grupo( ++i, #(length(res)<400), \
i, meter según ( si encontré un Magnanimous en 'i', res ))
 
#(utf8("Primeros 45 números magnánimos:\n")), #(res[1:45])
#(utf8("\n\nNúmeros magnánimos 241 - 250:\n")), #(res[241:250])
#(utf8("\n\nNúmeros magnánimos 391 - 400:\n")), #(res[391:400]), NL
luego imprime esto
 
terminar
 
subrutinas
 
encontrar un Magnanimous para(n)
tn=n, d=0, i=0, pd=0
iterar
último dígito de 'tn', mover a 'd,tn'
cuando ' tn ' { #( pd += ( d * 10^i ) ) }
mientras ' #( tn && is prime(tn+pd) ); ++i '
 
retornar ' #(not(tn)) '
</syntaxhighlight>
{{out}}
<pre>
Primeros 45 números magnánimos:
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
 
Números magnánimos 241 - 250:
17992,19972,20209,20261,20861,22061,22201,22801,22885,24407
 
Números magnánimos 391 - 400:
486685,488489,515116,533176,551558,559952,595592,595598,600881,602081
</pre>
 
Line 364 ⟶ 410:
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> DIM Sieve% 1E5
Prime%=2
WHILE Prime%^2 < 1E5
FOR S%=Prime%*2 TO 1E5 STEP Prime% Sieve%?S%=1 NEXT
REPEAT Prime%+=1 UNTIL Sieve%?Prime%=0
ENDWHILE
Sieve%?1=1
 
PRINT "First 45 magnanimous numbers"
REPEAT
IF M% > 9 THEN
FOR I%=LOGM% TO 1 STEP -1
IF Sieve%?((M% DIV 10^I%) + (M% MOD 10^I%)) EXIT FOR
NEXT
ENDIF
IF I% == 0 THEN
N%+=1
IF N% == 240 OR N% == 390 PRINT '"Magnanimous numbers ";N% + 1 "-";N% + 10
IF N% < 46 OR (N% > 240 AND N% < 251) OR (N% > 390 AND N% < 401) PRINT;M% " ";
ENDIF
M%+=1
UNTIL N% > 400</syntaxhighlight>
{{out}}
<pre>First 45 magnanimous numbers
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
Magnanimous numbers 241-250
17992 19972 20209 20261 20861 22061 22201 22801 22885 24407
Magnanimous numbers 391-400
486685 488489 515116 533176 551558 559952 595592 595598 600881 602081</pre>
 
=={{header|BCPL}}==
Line 3,836 ⟶ 3,914:
{{libheader|Wren-math}}
{{trans|Go}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv, Fmt
import "./math" for Int
var isMagnanimous = Fn.new { |n|
9,482

edits