Jump to content

Sum of the digits of n is substring of n: Difference between revisions

Realize in F#
(Add 8080 assembly)
(Realize in F#)
Line 312:
<pre>0 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 109 119 129 139 149 159 169 179 189 199 200 300 400 500 600 700 800 900 910 911 912 913 914 915 916 917 918 919</pre>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>
// Sum digits of n is substring of n: Nigel Galloway. April 16th., 2021
let rec fG n g=match (n/10,n%(if g<10 then 10 else 100)) with (_,n) when n=g->true |(0,_)->false |(n,_)->fG n g
let rec fN g=function n when n<10->n+g |n->fN(g+n%10)(n/10)
{1..999}|>Seq.filter(fun n->fG n (fN 0 n))|>Seq.iter(printf "%d "); printfn ""
</lang>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 109 119 129 139 149 159 169 179 189 199 200 300 400 500 600 700 800 900 910 911 912 913 914 915 916 917 918 919
Real: 00:00:00.003
</pre>
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.