Perfect totient numbers: Difference between revisions

Content added Content deleted
(add FreeBASIC)
m (→‎{{header|REXX}}: added whitespace.)
Line 1,163: Line 1,163:
<lang rexx>/*REXX program calculates and displays the first N perfect totient numbers. */
<lang rexx>/*REXX program calculates and displays the first N perfect totient numbers. */
parse arg N . /*obtain optional argument from the CL.*/
parse arg N . /*obtain optional argument from the CL.*/
if N=='' | N=="," then N= 20 /*Not specified? Then use the default.*/
if N=='' | N=="," then N= 20 /*Not specified? Then use the default.*/
@.=. /*memoization array of totient numbers.*/
@.= . /*memoization array of totient numbers.*/
p= 0 /*the count of perfect " " */
p= 0 /*the count of perfect " " */
$= /*list of the " " " */
$= /*list of the " " " */
Line 1,178: Line 1,178:
say 'The first ' N " perfect totient numbers:" /*display the header to the terminal. */
say 'The first ' N " perfect totient numbers:" /*display the header to the terminal. */
say strip($) /* " " list. " " " */
say strip($) /* " " list. " " " */
exit /*stick a fork in it, we're all done. */
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; return x
gcd: parse arg x,y; do until y==0; parse value x//y y with y x; end; return x
Line 1,199: Line 1,199:
<lang rexx>/*REXX program calculates and displays the first N perfect totient numbers. */
<lang rexx>/*REXX program calculates and displays the first N perfect totient numbers. */
parse arg N . /*obtain optional argument from the CL.*/
parse arg N . /*obtain optional argument from the CL.*/
if N=='' | N=="," then N= 20 /*Not specified? Then use the default.*/
if N=='' | N=="," then N= 20 /*Not specified? Then use the default.*/
@.=. /*memoization array of totient numbers.*/
@.= . /*memoization array of totient numbers.*/
p= 0 /*the count of perfect " " */
p= 0 /*the count of perfect " " */
$= /*list of the " " " */
$= /*list of the " " " */
Line 1,216: Line 1,216:
say 'The first ' N " perfect totient numbers:" /*display the header to the terminal. */
say 'The first ' N " perfect totient numbers:" /*display the header to the terminal. */
say strip($) /* " " list. " " " */
say strip($) /* " " list. " " " */
exit /*stick a fork in it, we're all done. */
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; return x
gcd: parse arg x,y; do until y==0; parse value x//y y with y x; end; return x