Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Totient-function/REXX/totient-function-1.rexx
Normal file
24
Task/Totient-function/REXX/totient-function-1.rexx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*REXX program calculates the totient numbers for a range of numbers, and count primes. */
|
||||
parse arg N . /*obtain optional argument from the CL.*/
|
||||
if N=='' | N=="," then N= 25 /*Not specified? Then use the default.*/
|
||||
tell= N>0 /*N positive>? Then display them all. */
|
||||
N= abs(N) /*use the absolute value of N for loop.*/
|
||||
w= length(N) /*W: is used in aligning the output. */
|
||||
primes= 0 /*the number of primes found (so far).*/
|
||||
/*if N was negative, only count primes.*/
|
||||
do j=1 for N; T= phi(j) /*obtain totient number for a number. */
|
||||
prime= word('(prime)', 1 + (T \== j-1 ) ) /*determine if J is a prime number. */
|
||||
if prime\=='' then primes= primes + 1 /*if a prime, then bump the prime count*/
|
||||
if tell then say 'totient number for ' right(j, w) " ──► " right(T, w) ' ' prime
|
||||
end /*j*/
|
||||
say
|
||||
say right(primes, w) ' primes detected for numbers up to and including ' N
|
||||
exit 0 /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
gcd: parse arg x,y; do until y==0; parse value x//y y with y x
|
||||
end /*until*/; return x
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
phi: procedure; parse arg z; if z==1 then return 1
|
||||
#= 1
|
||||
do m=2 for z-2; if gcd(m, z)==1 then #= # + 1
|
||||
end /*m*/; return #
|
||||
25
Task/Totient-function/REXX/totient-function-2.rexx
Normal file
25
Task/Totient-function/REXX/totient-function-2.rexx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*REXX program calculates the totient numbers for a range of numbers, and count primes. */
|
||||
parse arg N . /*obtain optional argument from the CL.*/
|
||||
if N=='' | N=="," then N= 25 /*Not specified? Then use the default.*/
|
||||
tell= N>0 /*N positive>? Then display them all. */
|
||||
N= abs(N) /*use the absolute value of N for loop.*/
|
||||
w= length(N) /*W: is used in aligning the output. */
|
||||
primes= 0 /*the number of primes found (so far).*/
|
||||
/*if N was negative, only count primes.*/
|
||||
do j=1 for N; T= phi(j) /*obtain totient number for a number. */
|
||||
prime= word('(prime)', 1 + (T \== j-1 ) ) /*determine if J is a prime number. */
|
||||
if prime\=='' then primes= primes + 1 /*if a prime, then bump the prime count*/
|
||||
if tell then say 'totient number for ' right(j, w) " ──► " right(T, w) ' ' prime
|
||||
end /*j*/
|
||||
say
|
||||
say right(primes, w) ' primes detected for numbers up to and including ' N
|
||||
exit 0 /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
phi: procedure; parse arg z; if z==1 then return 1
|
||||
#= 1
|
||||
do m=2 for z-2; parse value m z with x y
|
||||
do until y==0; parse value x//y y with y x
|
||||
end /*until*/
|
||||
if x==1 then #= # + 1
|
||||
end /*m*/
|
||||
return #
|
||||
Loading…
Add table
Add a link
Reference in a new issue