Untouchable numbers: Difference between revisions

→‎{{header|F_Sharp|F#}}: more dendrology, is 3 million enough?
m (→‎{{header|REXX}}: changed wording in the REXX section header.)
(→‎{{header|F_Sharp|F#}}: more dendrology, is 3 million enough?)
Line 68:
<lang fsharp>
// Applied dendrology. Nigel Galloway: February 15., 2021
let uT ga=let N,fNG=Array.create(ga+1) true,fG (int64 g) [|yield! primes64()|>Seq.takeWhile((>)(int64 ga))|]
let fN i (g::e as l)=let rec fN n x=match n with h::t->(let n=x+h in if n>i then None else fN t n) |_->Some((if x+g>i then [] else l),int x) in fN e 0L
let fGfN n (i:int64[]) g le=let mutable lp=le-1 in (fun()->lp<-lp+1; if lp<iG.Length then&& (fN n ((((g|>List.map((+i)*)(i1L+G.[lp])))@g)|>List-n*G.distinct)[p]<=(int64 a) then Some(n,i,lp) else (None,l))
let fG n i e=let g=n+i in let mutable n,l,p=n,1L,1L
let uT g=let N,fN=Array.create(g+1) true,fG (int64 g) [|yield! primes64()|>Seq.takeWhile((>)(int64 g))|]
let rec fG n g=match n() with (Somefun([],z),_)->Nn<-n*G.[ze]; p<-falsep*G.[e]; fGl<-l+p; nlet i=g*l-n in if i<=(int64 a) then Some(n,i,e) else None)
let rec fL n g=match n() with |(Some(f,i,z),e) ->N.[z(int i)]<-false; fGfL n ((fN f i (e+1)) (n::g)
|_->match g with n::gt->match n() with Some (n,i,e)->fL (fG n i e) g |_->N.[0]<-false;fL n t N
|_->N.[0]<-false; N
fGfL (fNfG [1L] 0L 0) [fN 1L 0L 1]
</lang>
===The Task===
Line 90 ⟶ 91:
1542 1566 1578 1588 1596 1632 1642 1650 1680 1682 1692 1716 1718 1728 1732 1746 1758 1766 1774 1776 1806 1816 1820 1822 1830 1838 1840 1842 1844 1852
1860 1866 1884 1888 1894 1896 1920 1922 1944 1956 1958 1960 1962 1972 1986 1992
</pre>
Real: 00:00:00.017, CPU: 00:00:00.015</pre>
;Count less than or equal 100000
<lang fsharp>
Line 98 ⟶ 99:
<pre>
13863
Real: 00:00:0502.396784, CPU: 00:00:0502.390</pre>750
</pre>
;Count less than or equal 1000000
Line 107 ⟶ 108:
<pre>
150232
Real: 00:0603:4008.494929, CPU: 00:0603:4008.125859
</pre>
;Count less than or equal 2000000
Line 116 ⟶ 117:
<pre>
305290
Real: 00:2111:5222.818325, CPU: 00:11:21:51.062828
</pre>
;Count less than or equal 2000000
<lang fsharp>
<lang fsharp>
printfn "%d" (uT 3000000|>Array.filter id|>Array.length)
</lang>
{{out}}
<pre>
462110
Real: 00:0024:00.017126, CPU: 00:0023:0059.015</pre>203
</pre>
 
2,172

edits