Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let say, I have a multiple 8. I have a initial value 48.7936628598344. Now, I need to make sure that 62 come in the series when I add multiple 8 with it's initial value.

Currently, 62 is not coming in the series.

48.7936628598344 + 1 * 8 = 56.79366286,

48.7936628598344 + 2 * 8 = 64.79366286,

48.7936628598344 + 3 * 8 = 72.79366286

What should I do the initial value 48.7936628598344

share|cite|improve this question
Got it, 48.7936628598344 + ( Mod(62,8)- Mod(48.7936628598344,8) ) = 54. Any suggestion will be appreciated. – user960567 Apr 13 '12 at 14:02
I have no idea what is going on here. What are you trying to do, construct a sequence here that starts at 48.whatever, eventually takes the value 62, and is somehow constructed via multiples of 8? – Neal Apr 13 '12 at 14:25
Please try to explain a bit better. – GarouDan Apr 13 '12 at 14:28
You have not provided any additional constraints, so you could just change the initial value to 62-8, right? – Rafał Dowgird Apr 13 '12 at 14:40
@RafałDowgird, You are correct but I need the number should be should be as near to 48.7936628598344 as possible. – user960567 Apr 14 '12 at 7:06
up vote 1 down vote accepted

Let's suppose that you search $n$ such that $62-8n$ is nearest of your input value $x$ then : $n=\operatorname{round}\left(\dfrac{62-x}8\right)$ so that the wanted integer could be : $$N=62-8\cdot\operatorname{round}\left(\dfrac{62-x}8\right)$$ If you want an integer larger than your input $x$ then use rather : $$N=62-8\cdot\operatorname{floor}\left(\dfrac{62-x}8\right)$$ (I'm supposing that you use a language 'C-like' where $\operatorname{floor}(x)$ returns an integer smaller than $x$)

Hoping this helped,

share|cite|improve this answer
Your solution does not work for me. Please provide an example with a starting point. – user960567 Apr 14 '12 at 9:17
@user960567: Let's use your $x=48.7936628598344$ then $n=\operatorname{round}\left(\dfrac{62-48.7936628598344}8\right)=2$ so that $N=62-2\cdot 8=46$ for the first and $n=1$, $N=54$ for the second. – Raymond Manzoni Apr 14 '12 at 9:21
Yup. This is correct. Thanks – user960567 Apr 14 '12 at 10:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.