Data update
This commit is contained in:
parent
8f05c7136f
commit
0bf4da02c3
82 changed files with 2194 additions and 118 deletions
50
Task/Totient-function/CLU/totient-function.clu
Normal file
50
Task/Totient-function/CLU/totient-function.clu
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
totient = proc (n: int) returns (int)
|
||||
tot: int := n
|
||||
|
||||
i: int := 2
|
||||
while i*i <= n do
|
||||
if n//i = 0 then
|
||||
while n//i = 0 do
|
||||
n := n/i
|
||||
end
|
||||
tot := tot-tot/i
|
||||
end
|
||||
if i=2 then i:=1 end
|
||||
i := i+2
|
||||
end
|
||||
if n>1 then
|
||||
tot := tot-tot/n
|
||||
end
|
||||
return(tot)
|
||||
end totient
|
||||
|
||||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
count: int := 0
|
||||
|
||||
stream$putl(po, " N Totient Prime")
|
||||
for n: int in int$from_to(1, 25) do
|
||||
tot: int := totient(n)
|
||||
stream$putright(po, int$unparse(n), 2)
|
||||
stream$putright(po, int$unparse(tot), 9)
|
||||
if n-1 = tot then
|
||||
stream$putright(po, "Yes", 7)
|
||||
count := count + 1
|
||||
else
|
||||
stream$putright(po, "No", 7)
|
||||
end
|
||||
stream$putl(po, "")
|
||||
end
|
||||
|
||||
stream$putl(po, "Number of primes up to 25:\t" || int$unparse(count))
|
||||
for n: int in int$from_to(26, 100000) do
|
||||
if totient(n) = n-1 then
|
||||
count := count + 1
|
||||
end
|
||||
if n = 100 cor n = 1000 cor n // 10000 = 0 then
|
||||
stream$putl(po, "Number of primes up to "
|
||||
|| int$unparse(n) || ":\t"
|
||||
|| int$unparse(count))
|
||||
end
|
||||
end
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue