Ulam numbers: Difference between revisions

(→‎{{header|Python}}: Extra ulam(100_000))
Line 17:
<br><br>
 
=={{header|AWK}}==
<lang AWK>
# syntax: GAWK -f ULAM_NUMBERS.AWK
BEGIN {
u = split("1,2",ulam,",")
for (n=3; ; n++) {
count = 0
for (x=1; x<=u-1; x++) {
for (y=x+1; y<=u; y++) {
if (ulam[x] + ulam[y] == n) {
count++
}
}
}
if (count == 1) {
ulam[++u] = n
if (u ~ /^(10|50|100|500|1000)$/) {
printf("%6d %6d\n",u,n)
if (++shown >= 5) { break }
}
}
}
exit(0)
}
</lang>
{{out}}
<pre>
10 18
50 253
100 690
500 5685
1000 12294
</pre>
=={{header|FreeBASIC}}==
<lang freebasic>redim as uinteger ulam(1 to 2)
477

edits