I need a formula to solve for specific increments

jdc6427

New member
Joined
Jun 23, 2006
Messages
1
I am looking for a calculation to solve the following math problem:

For any integer between 1 and 100000, how many of the following increments are there
1000
500
250
100
50
10
1

Example:
1042 contains the following
1 - 1000
0 - 500
0 - 250
0 - 100
0 - 50
4 - 10
2 - 1

:oops:
 
I'm not sure how you'd create a "formula" with only arithmetic (that is, without algebra). Are you sure the exercise requires that you create a "formula"?

Please reply with the full and exact text of the exercise, the complete instructions, and a clear listing of everything you have tried thus far. It would probably be helpful if you also listed topics which were studied recently in class, as this could help guide the tutors to providing you better advice.

Thank you.

Eliz.
 
There's no possible "formula", that's for sure!

You'd need a "user defined function" that receives number n,
then returns 7 results: for 1000, 500, 250, 100, 50, 10, 1

Modular division would be required; like 5047 \ 1000 = 5;
"5" would be one of the returned results.

Using your 1042 as example, n = 1042, returned is a, b, c, d, e, f, g,
and function goes like this:
a = n \ 1000 : 1042 \ 1000 = 1
n = n - a*1000 : n = 1042 - 1*1000 = 42

b = n \ 500 : 42 \ 500 = 0
n = n - b*500 : n = 42 - 0*500 = 42

this would continue similarly for c, d, e: all will equal 0

f = n \ 10 : 42 \ 10 = 4
n = n - f*10 : n = 42 - 4*10 = 2

g = n : g = 2

So returned will be: 1,0,0,0,0,4,2
 
for any number n
a=n/1000 rounded down
b=n/500 rounded down
c=n/250 rounded down
d=n/100 rounded down
e=n/50 rounded down
f=n/10 rounded down
g=n/1 rounded down

x= a+b+c+d+e+f+g
 
That's not correct, mcrae: can you see why?

n=2000
2000/1000 = 2
2000/500 = 4
2000/250 = 8
and so on...BUT you must use n=0 after 2000/1000, so b to g = 0
 
Top