Numbers in base 10 that are palindromic in bases 2, 4, and 16: Difference between revisions
Numbers in base 10 that are palindromic in bases 2, 4, and 16 (view source)
Revision as of 18:29, 25 June 2021
, 3 years agoRealize in F#
m (→{{header|ALGOL 68}}: Remove spurious "primes" from a comment) |
(Realize in F#) |
||
Line 270:
3855 4095 4097 4369 12291 13107 20485 21845</pre>
=={{header|F_Sharp|F#}}==
<lang fsharp>
// Palandromic numbers in bases 2,4, and 16. Nigel Galloway: June 25th., 2021
let fG n g=let rec fG n g=[yield n%g; if n>=g then yield! fG(n/g) g] in let n=fG n g in n=List.rev n
Seq.initInfinite id|>Seq.takeWhile((>)25000)|>Seq.filter(fun g->fG g 16 && fG g 4 && fG g 2)|>Seq.iter(printf "%d "); printfn ""
</lang>
{{out}}
<pre>
0 1 3 5 15 17 51 85 255 257 273 771 819 1285 1365 3855 4095 4097 4369 12291 13107 20485 21845
</pre>
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
|