RosettaCodeData/Task/Casting-out-nines/ABC/casting-out-nines.abc
2024-04-20 12:30:13 -07:00

12 lines
388 B
Text

\ casting out nines - based on the Action! sample
HOW TO ADD v TO n: PUT n + v IN n
PUT 10, 2, 0, 0 IN base, n, count, total
FOR i IN { 1 .. base ** n }:
ADD 1 TO total
IF i mod ( base - 1 ) = ( i * i ) mod ( base - 1 ):
ADD 1 TO count
WRITE i
WRITE // "Trying", count, "numbers instead of", total, "numbers saves"
WRITE 100 - ( ( 100 * count ) / total ), "%" /