Data update
This commit is contained in:
parent
8f05c7136f
commit
0bf4da02c3
82 changed files with 2194 additions and 118 deletions
31
Task/Totient-function/BCPL/totient-function.bcpl
Normal file
31
Task/Totient-function/BCPL/totient-function.bcpl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
get "libhdr"
|
||||
|
||||
let totient(n) = valof
|
||||
$( let tot = n and i = 2
|
||||
while i*i <= n
|
||||
$( if n rem i = 0
|
||||
$( while n rem i = 0 do n := n / i
|
||||
tot := tot - tot/i
|
||||
$)
|
||||
if i=2 then i:=1
|
||||
i := i+2
|
||||
$)
|
||||
resultis n>1 -> tot-tot/n, tot
|
||||
$)
|
||||
|
||||
let start() be
|
||||
$( let count = 0
|
||||
writes(" N Totient Prime*N")
|
||||
for n = 1 to 25
|
||||
$( let tot = totient(n)
|
||||
let prime = n-1 = tot
|
||||
if prime then count := count + 1
|
||||
writef("%I2 %I7 %S*N", n, tot, prime -> " Yes", " No")
|
||||
$)
|
||||
writef("Number of primes up to %I6: %I4*N", 25, count)
|
||||
for n = 26 to 10000
|
||||
$( if totient(n) = n-1 then count := count + 1
|
||||
if n = 100 | n = 1000 | n = 10000 then
|
||||
writef("Number of primes up to %I6: %I4*N", n, count)
|
||||
$)
|
||||
$)
|
||||
Loading…
Add table
Add a link
Reference in a new issue