Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # totientit 1...n using Gauss divisor sum property
- # idea https://cp-algorithms.com/algebra/phi-function.html
- # Juhani Kaukoranta 4.4.2021
- # Julia-ohjelma Gausstotientit.jl
- function Gausstotientit(n)
- phi =Vector{Int64}(undef,n)
- phi[1]=1
- phi[2]=1
- for i = 2:n
- phi[i] = i-1
- end
- for i = 2:n
- for j = 2*i : i : n
- phi[j] -= phi[i]
- end
- end
- return phi
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement