Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Totient-function/Arturo/totient-function.arturo
Normal file
28
Task/Totient-function/Arturo/totient-function.arturo
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
totient: function [n][
|
||||
tot: new n
|
||||
i: 2
|
||||
while -> n >= i * i [
|
||||
if 0 = n % i [
|
||||
while -> 0 = n % i -> n: n / i
|
||||
'tot - tot / i
|
||||
]
|
||||
if 2 = i -> i: 1
|
||||
'i + 2
|
||||
]
|
||||
if n > 1 -> 'tot - tot / n
|
||||
return tot
|
||||
]
|
||||
|
||||
primes: 0
|
||||
loop 1..100000 'i [
|
||||
t: totient i
|
||||
prime?: 1 = i - t
|
||||
if i < 26 [
|
||||
prints ~« Φ(|pad.with:`0` to :string i 2|) = |pad to :string t 2|
|
||||
if prime? -> prints ", prime"
|
||||
print ""
|
||||
]
|
||||
if 50 = i -> print ""
|
||||
if in? i [100 1000 10000 100000] -> print ~« |primes| primes =< |i|
|
||||
if prime? -> 'primes + 1
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue