Data update
This commit is contained in:
parent
8f05c7136f
commit
0bf4da02c3
82 changed files with 2194 additions and 118 deletions
39
Task/Totient-function/Draco/totient-function.draco
Normal file
39
Task/Totient-function/Draco/totient-function.draco
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
proc totient(word n) word:
|
||||
word tot, i;
|
||||
tot := n;
|
||||
i := 2;
|
||||
while i*i <= n do
|
||||
if n%i = 0 then
|
||||
while n%i = 0 do n := n/i od;
|
||||
tot := tot - tot/i
|
||||
fi;
|
||||
if i=2 then i:=1 fi;
|
||||
i := i+2
|
||||
od;
|
||||
if n>1 then
|
||||
tot - tot/n
|
||||
else
|
||||
tot
|
||||
fi
|
||||
corp
|
||||
|
||||
proc main() void:
|
||||
word count, n, tot;
|
||||
bool prime;
|
||||
|
||||
count := 0;
|
||||
writeln(" N Totient Prime");
|
||||
for n from 1 upto 25 do
|
||||
tot := totient(n);
|
||||
prime := n-1 = tot;
|
||||
if prime then count := count+1 fi;
|
||||
writeln(n:2, " ", tot:7, " ", if prime then " Yes" else " No" fi)
|
||||
od;
|
||||
writeln("Number of primes up to ",25:6,": ",count:4);
|
||||
for n from 25 upto 10000 do
|
||||
if totient(n) = n-1 then count := count+1 fi;
|
||||
if n=100 or n=1000 or n=10000 then
|
||||
writeln("Number of primes up to ",n:6,": ",count:4)
|
||||
fi
|
||||
od
|
||||
corp
|
||||
Loading…
Add table
Add a link
Reference in a new issue