Jump to content

Totient function: Difference between revisions

easylang
m (→‎{{header|Quackery}}: point to definition of gcd)
(easylang)
Line 2,483:
Number of primes up to 90000 = 8713
Number of primes up to 100000 = 9592</pre>
 
=={{header|EasyLang}}==
{{trans|AWK}}
<syntaxhighlight lang="easylang">
func totient n .
tot = n
i = 2
while i <= sqrt n
if n mod i = 0
while n mod i = 0
n = n div i
.
tot -= tot div i
.
if i = 2
i = 1
.
i += 2
.
if n > 1
tot -= tot div n
.
return tot
.
numfmt 0 3
print " N Prim Phi"
for n = 1 to 25
tot = totient n
x$ = " "
if n - 1 = tot
x$ = " x "
.
print n & x$ & tot
.
print ""
for n = 1 to 100000
tot = totient n
if n - 1 = tot
cnt += 1
.
if n = 100 or n = 1000 or n = 10000 or n = 100000
print n & " - " & cnt & " primes"
.
.
</syntaxhighlight>
 
 
=={{header|Factor}}==
2,053

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.