0
$\begingroup$

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

  • 2
    Got it, 48.7936628598344 + ( Mod(62,8)- Mod(48.7936628598344,8) ) = 54. Any suggestion will be appreciated.2012-04-13
  • 1
    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?2012-04-13
  • 0
    Please try to explain a bit better.2012-04-13
  • 0
    You have not provided any additional constraints, so you could just change the initial value to 62-8, right?2012-04-13
  • 0
    @RafałDowgird, You are correct but I need the number should be should be as near to 48.7936628598344 as possible.2012-04-14
  • 0
    @GarouDan, I need to start series at a point near to 48.7936628598344 with a multiple of 8. But this series must include a number 62. Sorry for late. Any Solution(other than me) will be appreciated.2012-04-14
  • 0
    @Neal, see above comment.2012-04-14

1 Answers 1

1

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,

  • 0
    Your solution does not work for me. Please provide an example with a starting point.2012-04-14
  • 0
    @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.2012-04-14
  • 0
    Yup. This is correct. Thanks2012-04-14