Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lauren has 20 coins in her piggy bank, all dimes and quarters. The total amount of money is $3.05. How many of each coin does she have?

share|improve this question

closed as off-topic by Mike Honeychurch, m_goldberg, RunnyKine, Sjoerd C. de Vries, Pinguin Dirk Jan 27 '14 at 8:46

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

A perfect place to use FindInstance:

FindInstance[n1*10 + n2*25 == 305 && n1 + n2 == 20, {n1, n2}]
{{n1 -> 13, n2 -> 7}}

So Lauren has 7 quarters and 13 dimes.

share|improve this answer

This is a linear Diophantine equation in two variables: $10x+25y=305$. Generating functions give the number of solutions for coin change problems like this. For example,

GFCoinPartitions[n_, d_List]:= Block[{z}, 
   Coefficient[Series[Product[1/(1-z^d[[i]]), {i,1,Length[d]}], {z,0,n}], z, n]]

wherenis the total to find, 305 pennies in this case, anddis a list of coin denominations, 10 and 25 in this case. There are 6 solutions to this problem. The ever popularFrobeniusSolvefinds them by using:

FrobeniusSolve[{10, 25}, 305]
(* {{3, 11}, {8, 9}, {13, 7}, {18, 5}, {23, 3}, {28, 1}} *)
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.