Magnanimous numbers: Difference between revisions

add FreeBASIC
(add FreeBASIC)
Line 590:
486685 488489 515116 533176 551558 559952 595592 595598 600881 602081
</pre>
 
=={{header|FreeBASIC}}==
<lang freebasic>
#include "isprime.bas"
 
dim as uinteger magn(0 to 399), i, n=10, j
dim as string ns, lefty, righty
for i = 0 to 9
magn(i) = i 'all single digit ints are magnanimous by definition
next i
 
while i<400
n += 1
ns = str(n)
for j = 1 to len(ns)-1
lefty = left(ns, j)
righty = right(ns, len(ns)-j)
if not isprime( val(lefty) + val(righty) ) then continue while
next j
magn(i) = n
i+=1
wend
 
for i=0 to 44
print i+1,magn(i)
next i
 
for i=240 to 249
print i+1,magn(i)
next i
 
for i=390 to 399
print i+1,magn(i)
next i
</lang>
{{out}}
<pre>1 0
2 1
3 2
4 3
5 4
6 5
7 6
8 7
9 8
10 9
11 11
12 12
13 14
14 16
15 20
16 21
17 23
18 25
19 29
20 30
21 32
22 34
23 38
24 41
25 43
26 47
27 49
28 50
29 52
30 56
31 58
32 61
33 65
34 67
35 70
36 74
37 76
38 83
39 85
40 89
41 92
42 94
43 98
44 101
45 110
241 17992
242 19972
243 20209
244 20261
245 20861
246 22061
247 22201
248 22801
249 22885
250 24407
391 486685
392 488489
393 515116
394 533176
395 551558
396 559952
397 595592
398 595598
399 600881
400 602081</pre>
 
=={{header|Go}}==
781

edits