Totient function: Difference between revisions

Added 11l
m (-fix)
(Added 11l)
Line 45:
::*   [[oeis:/A000010|OEIS: Euler totient function phi(n)]].
<br/>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>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 Set([100, 1000, 10'000])
print(‘Primes up to #.: #.’.format(n, count))</lang>
 
{{out}}
<pre>
f(1) == 1
f(2) == 1, is prime
f(3) == 2, is prime
f(4) == 2
f(5) == 4, is prime
f(6) == 2
f(7) == 6, is prime
f(8) == 4
f(9) == 6
f(10) == 4
f(11) == 10, is prime
f(12) == 4
f(13) == 12, is prime
f(14) == 6
f(15) == 8
f(16) == 8
f(17) == 16, is prime
f(18) == 6
f(19) == 18, is prime
f(20) == 8
f(21) == 12
f(22) == 10
f(23) == 22, is prime
f(24) == 8
f(25) == 20
Primes up to 100: 25
Primes up to 1000: 168
Primes up to 10000: 1229
</pre>
 
=={{header|Ada}}==
1,480

edits