I have the equation 6a+9b+20c=n with n being the total number of McNuggets, and the "a" "b" "c" being the pack combos of McNuggets. Now, for n, there are different combinations that can be used to get n where n >= 6. The problem asks that I should be able to find the largest number of McNuggets that cannot be bought in exact quantity. I really have no idea how to solve this. The problem before asked me to ask for n and give possible combos, here's the code for the previous program:
#include <stdio.h>
#include <math.h>
void find_mcnugget(void); //creates a function. This function will be used later on in the program
int n, a, b, c; // variables for the packs and the total amount
int main()
{
printf ("Enter the number of McNuggets you want in total:");//asks user for the total number of Mcnuggets that he wants
scanf ("%d", &n);//stores the user's input
if (n<6) printf("Please input a number greater than 5 \n");//since least number of Mcnuggets is 6, user has to enter 6 or above
else find_mcnugget();//if the number is over 6, continue
system("PAUSE");
return 0;
}
void find_mcnugget(){//using the function created above
for(a=0;a<=n;a++){//creating equation of the 6-pack
for(b=0;b<=n;b++){//creating equation of the 9-pack
for(c=0;c<=n;c++){//creating equation of the 20-pack
if((6*a)+(9*b)+(20*c)==n) printf("%d Mcnuggets: You get %d packs of 6, %d packs of 9, %d packs of 20\n", n, a, b, c);//gives the possible combos
}
}
}
}
If anyone can help, not necessarily provide the code, just give me a hint or some clue how to do this, thanks.