- May 7, 2013
- 10,400
McNugget Numbers are any integer n, which can be satisfied with the linear combination of 6a + 9b + 20c.
All integers are McNugget Numbers with exception of {1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 22, 23, 25, 28, 31, 34, 37, 43}, if we use the original box size set of {6, 9, 20}.
I've designed this small program to test if a number is potentially a McNugget Number. It will quickly sieve through if the number is able to satisfied with a x6 McNugget Box, a x9 McNugget Box or a x20 McNugget Box. Note that the program doesn't consider all the possible ways of satisfying some integer n.
For example, 36 can be satisfied with {6,0,0}, {0,4,0} and {3,2,0}.
Source: McNugget Number -- from Wolfram MathWorld
All integers are McNugget Numbers with exception of {1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 22, 23, 25, 28, 31, 34, 37, 43}, if we use the original box size set of {6, 9, 20}.
I've designed this small program to test if a number is potentially a McNugget Number. It will quickly sieve through if the number is able to satisfied with a x6 McNugget Box, a x9 McNugget Box or a x20 McNugget Box. Note that the program doesn't consider all the possible ways of satisfying some integer n.
For example, 36 can be satisfied with {6,0,0}, {0,4,0} and {3,2,0}.
Code:
#include <iostream>
int size_6 (int n, int a) {
a = n / 6;
return a;
}
int size_9 (int n, int b) {
b = n / 9;
return b;
}
int size_20 (int n, int c) {
c = n / 20;
return c;
}
int main() {
int n; //User Input, n to check
int a, b, c = 0; //number of possible 6, 9 or 20 size boxes to satisify n
std::cout << "Welcome to the McNugget Number Checker.\n";
std::cout << "Which number would like to check?\n";
std::cout << "Enter a number: ";
std::cin >> n;
std::cin.ignore();
if (n % 6 == 0) {
std::cout << "{" << size_6(n,a) << ",0,0}\n";
}
else {
std::cout << n << " can't be satisfied with just a x6 McNugget Box\n";
}
if (n % 9 == 0) {
std::cout << "{0," << size_9(n,b) << ",0}\n";
}
else {
std::cout << n << " can't be satisfied with just a x9 McNugget Box\n";
}
if (n % 20 == 0) {
std::cout << "{0,0," << size_20(n,c) << "}\n";
}
else {
std::cout << n << " can't be satisified with just a x20 McNugget Box\n";
}
if (n % 6 != 0 && n % 9 != 0 && n % 20 != 0) {
std::cout << n << " is possibly not a McNugget Number";
}
std::cin.get();
return 0;
}
Source: McNugget Number -- from Wolfram MathWorld
Last edited: