I have two integers ( input & output )
when input >= 1 and <= 100000 , output will 20
when input >= 100001 and <= 200000 , output will 30
when input >= 200001 and <= 300000 , output will 40
when input >= 300001 and <= 400000 , output will 50
when input >= 400001 and <= 500000 , output will 60
...
...
and so on.
Max range of input is unlimited
How can I manage it in C#
CodePudding user response:
output = (ceil(input/100000) 1)*10
The ceil function basically rounds above a float to an integer.
CodePudding user response:
Simple arithemtic along with integer division should do the trick
var output = (input / 100000) * 10 20;
If the input
is a floating point or decimal already then use Math.Floor