Find formula

ravininave

New member
Joined
Aug 13, 2021
Messages
7
If any amount is <=100000 then answer should be 10
If any >100000 and <=200000 then 20
Like after every 100000 amt answer should increase by 10
How can we make a formula to calculate answer of any amount like this. Like answer of 501543 should be 60
 
If any amount is <=100000 then answer should be 10
If any >100000 and <=200000 then 20
Like after every 100000 amt answer should increase by 10
How can we make a formula to calculate answer of any amount like this. Like answer of 501543 should be 60
Are you familiar with floor function, or ceiling function or MOD function?

Please show us what you have tried and exactly where you are stuck.

Please follow the rules of posting in this forum, as enunciated at:


Please share your work/thoughts about this problem.
 
Yes I know these functions but unfortunately I was unable to set the logic with this.
 
If any amount is <=100000 then answer should be 10
If any >100000 and <=200000 then 20
Like after every 100000 amt answer should increase by 10
How can we make a formula to calculate answer of any amount like this. Like answer of 501543 should be 60
If the question was:

If any amount is <=1 then answer should be 1
If any >1 and <=2 then 2
Like after every 1 amt answer should increase by 1 ......................................edited
How can we make a formula to calculate answer of any amount like this. Like answer of 5.01543 should be 6
Can you work with the problem above?
 
Last edited by a moderator:
Yes I know these functions but unfortunately I was unable to set the logic with this.
Can anyone suggest a way
You've been given suggestions, but haven't shown us anything about what you can understand, so we can give appropriate help. If you make even the poorest attempt, we'll be able to correct it.

I'll give you a more specific suggestion: Try graphing y = floor(x/100,000) and see how it compares to what you want. (I've intentionally not given you the final answer, because I want you to have to make a couple changes to make it work. Part of problem solving is to try things and adjust.)
 
You've been given suggestions, but haven't shown us anything about what you can understand, so we can give appropriate help. If you make even the poorest attempt, we'll be able to correct it.

I'll give you a more specific suggestion: Try graphing y = floor(x/100,000) and see how it compares to what you want. (I've intentionally not given you the final answer, because I want you to have to make a couple changes to make it work. Part of problem solving is to try things and adjust.)
Yeh it completely solved my problem. I tried it with lots of different amount and it worked well. Thank you!
 
Yeh it completely solved my problem. I tried it with lots of different amount and it worked well. Thank you!
I hope you mean that you made two modifications in order to solve your problem! What I suggested is wrong in two ways, and was intended only as a starting point.
 
I hope you mean that you made two modifications in order to solve your problem! What I suggested is wrong in two ways, and was intended only as a starting point.
Your answer was correct I made small change in it like:

floor( (954821/100000)+1 )* 10)

and answer is correct for every figure
 
Your answer was correct I made small change in it like:

floor( (954821/100000)+1 )* 10)

and answer is correct for every figure
Not quite. Multiplying by 10 was one of the changes needed; but adding 1 doesn't quite do it.

If any amount is <=100000 then answer should be 10
If any >100000 and <=200000 then 20
You want 100,000, or anything a little less than that, to produce 10. But your function, f(x) = floor(x/100,000 + 1)*10, doesn't quite do that. It's true that f(99,999) = floor(99,999/100,000 + 1)*10 = 10; but f(100,000) = floor(100,000/100,000 + 1)*10 = 20. You wanted that to still be 10, while anything above that gives 20.

How about using the ceiling function, rather than the floor? In other words, round up rather than down!
 
Not quite. Multiplying by 10 was one of the changes needed; but adding 1 doesn't quite do it.


You want 100,000, or anything a little less than that, to produce 10. But your function, f(x) = floor(x/100,000 + 1)*10, doesn't quite do that. It's true that f(99,999) = floor(99,999/100,000 + 1)*10 = 10; but f(100,000) = floor(100,000/100,000 + 1)*10 = 20. You wanted that to still be 10, while anything above that gives 20.

How about using the ceiling function, rather than the floor? In other words, round up rather than down!
 
floor( ((100000-1)/100000)+1 )* 10)
I assume you mean that your new function is f(x) = floor( ((x-1)/100 000)+1 )*10. (Please make sure your parentheses balance!)

Let's check it again. We want f(99 999) = 10, f(100 000) = 10, and f(100 001) = 20. We get

f(99 999) = floor( ((99 999-1)/100 000)+1 )*10 = floor(1.99998)*10 = 10​
f(100 000) = floor( ((100 000-1)/100 000)+1 )*10 = floor(1.99999)*10 = 10​
f(100 001) = floor( ((100 001-1)/100 000)+1 )*10 = floor(2)*10 = 20​

Good. But we also want f(100 000.1) = 20:

f(100 000.1) = floor( ((100 000.1-1)/100 000)+1 )*10 = floor(1.999991)*10 = 10​

Please think about the difference between floor and ceiling. I've mentioned it for a reason. Floor increases at an integer, while ceiling increases "immediately after" an integer. Which graph matches what you want?
 
Top