RosettaCodeData/Task/Totient-function/11l/totient-function.11l

14 lines
341 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
F f(n)
R sum((1..n).filter(k -> gcd(@n, k) == 1).map(k -> 1))
F is_prime(n)
R f(n) == n - 1
L(n) 1..25
print( f(#.) == #..format(n, f(n))(I is_prime(n) {, is prime} E ))
V count = 0
L(n) 1..10'000
count += is_prime(n)
I n C (100, 1000, 10'000)
print(Primes up to #.: #..format(n, count))