Solving Diophantine Equations Using Python

Posted by HARSHITH on Stack Overflow See other posts from Stack Overflow or by HARSHITH
Published on 2010-06-16T03:06:05Z Indexed on 2010/06/16 3:12 UTC
Read the original article Hit count: 1191

Filed under:

In mathematics, a Diophantine equation (named for Diophantus of Alexandria, a third century Greek mathematician) is a polynomial equation where the variables can only take on integer values. Although you may not realize it, you have seen Diophantine equations before: one of the most famous Diophantine equations is:

We are not certain that McDonald's knows about Diophantine equations (actually we doubt that they do), but they use them! McDonald's sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 nuggets, since no non- negative integer combination of 6's, 9's and 20's adds up to 16. To determine if it is possible to buy exactly n McNuggets, one has to solve a Diophantine equation: find non-negative integer values of a, b, and c, such that

        6a + 9b + 20c = n.

Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n):

"Largest number of McNuggets that cannot be bought in exact quantity: n"

© Stack Overflow or respective owner

Related posts about diophantine

  • Solving Diophantine Equations Using Python

    as seen on Stack Overflow - Search for 'Stack Overflow'
    In mathematics, a Diophantine equation (named for Diophantus of Alexandria, a third century Greek mathematician) is a polynomial equation where the variables can only take on integer values. Although you may not realize it, you have seen Diophantine equations before: one of the most famous Diophantine… >>> More

  • Diophantine Equation [closed]

    as seen on Stack Overflow - Search for 'Stack Overflow'
    In mathematics, a Diophantine equation (named for Diophantus of Alexandria, a third century Greek mathematician) is a polynomial equation where the variables can only take on integer values. Although you may not realize it, you have seen Diophantine equations before: one of the most famous Diophantine… >>> More

  • Diophantine Equation

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Show that it is possible to buy exactly 50, 51, 52, 53, 54, and 55 McNuggets, by finding solutions to the Diophantine equation. You can solve this in your head, using paper and pencil, or writing a program. However you chose to solve this problem, list the combinations of 6, 9 and 20 packs of McNuggets… >>> More

  • diophantine equation

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n): "Largest number of McNuggets that cannot be bought in exact quantity: n" in… >>> More

  • Diophantine Equation

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n): "Largest number of McNuggets that cannot be bought in exact quantity: n" Hints: Hypothesize… >>> More