Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/Totient-function/Zkl/totient-function-1.zkl
Normal file
2
Task/Totient-function/Zkl/totient-function-1.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fcn totient(n){ [1..n].reduce('wrap(p,k){ p + (n.gcd(k)==1) }) }
|
||||
fcn isPrime(n){ totient(n)==(n - 1) }
|
||||
4
Task/Totient-function/Zkl/totient-function-2.zkl
Normal file
4
Task/Totient-function/Zkl/totient-function-2.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
foreach n in ([1..25]){
|
||||
println("\u03c6(%2d) ==%3d %s"
|
||||
.fmt(n,totient(n),isPrime(n) and "is prime" or ""));
|
||||
}
|
||||
6
Task/Totient-function/Zkl/totient-function-3.zkl
Normal file
6
Task/Totient-function/Zkl/totient-function-3.zkl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
count:=0;
|
||||
foreach n in ([1..10_000]){ // yes, this is sloooow
|
||||
count+=isPrime(n);
|
||||
if(n==100 or n==1000 or n==10_000)
|
||||
println("Primes <= %,6d : %,5d".fmt(n,count));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue