RosettaCodeData/Task/McNuggets-problem/Modula-2/mcnuggets-problem.mod2

27 lines
553 B
Plaintext

MODULE McNuggets;
FROM InOut IMPORT WriteCard, WriteString, WriteLn;
CONST Max = 100;
VAR a, b, c: CARDINAL;
nugget: ARRAY [0..Max] OF BOOLEAN;
BEGIN
FOR a := 0 TO Max DO
nugget[a] := FALSE;
END;
FOR a := 0 TO Max BY 6 DO
FOR b := a TO Max BY 9 DO
FOR c := b TO Max BY 20 DO
nugget[c] := TRUE;
END;
END;
END;
a := 100;
REPEAT DEC(a); UNTIL NOT nugget[a];
WriteString("Maximum non-McNuggets number: ");
WriteCard(a, 2);
WriteLn();
END McNuggets.