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
  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.

6 Years
Discussion Span
Last Post by Adak

Please forget about the previous problem and the code that solved it - it puts the focus on something that is not the NOW problem. That's what to focus on.

As you stated the problem, the answer is there is a HUGE number of n, that can't be exactly equaled by any combination of 6, 9, and 20. Somehow, the problem has to limit the size of n.

Explain that, and then we can talk turkey, er chicken, about this problem. ;)

Edited by Adak: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.