How to resolve the algorithm McNuggets problem step by step in the XPL0 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm McNuggets problem step by step in the XPL0 programming language
Table of Contents
Problem Statement
Calculate (from 0 up to a limit of 100) the largest non-McNuggets number (a number n which cannot be expressed with 6x + 9y + 20z = n where x, y and z are natural numbers).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm McNuggets problem step by step in the XPL0 programming language
Source code in the xpl0 programming language
int N, A(101), X, Y, Z;
[for N:= 0 to 100 do A(N):= false;
for X:= 0 to 100/6 do
for Y:= 0 to 100/9 do
for Z:= 0 to 100/20 do
[N:= 6*X + 9*Y + 20*Z;
if N <= 100 then A(N):= true;
];
for N:= 100 downto 0 do
if A(N) = false then
[IntOut(0, N);
exit;
];
]
You may also check:How to resolve the algorithm Word wrap step by step in the VBScript programming language
You may also check:How to resolve the algorithm Substitution cipher step by step in the C# programming language
You may also check:How to resolve the algorithm Show the epoch step by step in the Pascal programming language
You may also check:How to resolve the algorithm Numbers with equal rises and falls step by step in the C programming language
You may also check:How to resolve the algorithm Stern-Brocot sequence step by step in the PARI/GP programming language