RosettaCodeData/Task/McNuggets-problem/Agena/mcnuggets-problem.agena
2026-04-30 12:34:36 -04:00

19 lines
669 B
Text

scope # Solve the McNuggets problem: find the largest n <= 100 for which there
# are no non-negative integers x, y, z such that 6x + 9y + 20z = n
local constant maxNuggets := 100;
local sum := [];
for i from 0 to maxNuggets do sum[ i ] := false od;
for x from 0 to maxNuggets by 6 do
for y from x to maxNuggets by 9 do
for z from y to maxNuggets by 20 do
sum[ z ] := true
od
od
od;
# show the highest number that cannot be formed
local largest := maxNuggets;
while sum[ largest ] do largest -:= 1 od;
printf( "The largest non McNugget number is: %d\n", largest )
epocs