MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Making Change, once more


Sorry, I missed the point in the definition of numberChanges. Of course
it should be

In[8]:= numberChanges[x_,1]=1;

In[9]:= numberChanges[x_,n_]:=numberChanges=
  Sum[numberChanges[x-k coins[[-n]],n-1],{k,0,Quotient[x,coins[[-n]]]}]

In[11]:= numberChanges[x_]:=numberChanges[x,6]

In[12]:= numberChanges[100]

Out[12]= 293

And now I can get the answer for 10 dollars:

In[13]:= Timing[numberChanges[1000]]

Out[13]= {1.37 Second,2103596}

Jurgen


Wilson Figueroa wrote:
> 
> Hello Group,
> 
> I have a question pertaining to making change.
> 
etc.



  • Prev by Date: Compile and NormalDistribution
  • Next by Date: Re: combinatorics
  • Previous by thread: Re: Re: Compile and NormalDistribution
  • Next by thread: Solving with restrictions on parameters