[Cialug] Algorithm

Jerry Weida cialug@cialug.org
Fri, 14 Jan 2005 18:55:37 -0600


not sure if this counts as "logic" but here's how I'd do it:

quarters = amount / 25
amount = amount - quarters * 25
dimes = amount / 10
amount = amount - dimes * 10
nickels = amount / 5
amount = amount - nickels * 5
pennies = amount


On Fri, 14 Jan 2005 18:34:40 -0600, Morris Dovey <mrdovey@iedu.com> wrote:
> David Stout wrote:
> 
> > Without using logic just integer arithmetic what would the
> > algorithm be for finding how many quarters, dimes, nickles &
> > penneys in .92.
> 
> Pennies <- 100 * Amount
> Quarters <- Pennies / 25
> Pennies <- Pennies - Quarters * 25
> Dimes <- Pennies / 10
> Pennies <- Pennies - Dimes * 10
> Nickles <- Pennies / 5
> Pennies <- Pennies - Nickles * 5
> 
> --
> Morris Dovey
> West Des Moines, Iowa USA
> 
> _______________________________________________
> Cialug mailing list
> Cialug@cialug.org
> http://cialug.org/mailman/listinfo/cialug
>