Undulating numbers: Difference between revisions

m (→‎{{header|ALGOL 68}}: Remove unused variable)
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
commatise( whole( undulating number( d, f, s, b ), 0 ) );
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 #
3,038

edits