Undulating numbers: Difference between revisions
→{{header|ALGOL 68}}: Biug fix
m (→{{header|ALGOL 68}}: Remove unused variable) |
(→{{header|ALGOL 68}}: Biug fix) |
||
Line 84:
# with first digit f and second digit s with d digits in total #
PROC undulating string = ( INT d, f, s, b )STRING:
BEGIN
STRING un := "";
CHAR fc = REPR ( f + ABS "0" );
CHAR sc = REPR ( s + ABS "0" );
FOR digit FROM d BY -1 TO 1 DO
IF ODD digit THEN fc ELSE sc FI +=: un
OD;
commatise( un )
END # undulating string # ;
# prints the undulating numbers with d digits in base b #
# if primes only is TRUE, only prime undulating numbers are shown #
|