Take the 2-minute tour ×
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.

Given that:

  1. $91 \le a \le 100$

  2. $a + ( 10 * b ) = c $

  3. $a$ and $b$ both are int ( not float values. ie. The values are not fraction )

  4. Value of $c$ is any random value (eg. $108$)

What's the value of $a$ and $b$ for $c$ (eg. $c = 108$)?

(For example, by guessing, I got $a = 98$ and $b = 1$).

But I just want to come up with some single line mathematical formula, not a for-loop based algorithm that checks values one by one.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Let us define $d=a-91$, so $0 \le d \le 9$.
$d=(c-91) \pmod {10}$

$b=\lfloor \frac {c-91}{10} \rfloor=\frac {c-a}{10}$

$a=d+91$

Basically, $d$ is the ones digit of $c-91$ and $b$ is all the rest of the digits.

share|improve this answer
    
Thankyou!.. But, I took a random value of c = 128 So, d = ( 128 - 91 ) mod 10 ==> 37 mod 10 ==> 7 AND THEN, b = ( 128 -91 )/ 10 ==> 37/10 = 3.7 (which is a float value not an int ) ?? –  Vishwas Gagrani Sep 6 '12 at 13:59
    
@VishwasGagrani: forgot the floor function. Fixed now. You can also subtract $d$ which will give a multiple of $10$ –  Ross Millikan Sep 6 '12 at 14:17

Say b>= 0 and if a = 91, then c can be, 91, 101, 111,... if a = 92, c can be, 92,102...

Similarly for others, so if c mod 10 = x; then a = 9x.

so b = (c - a)/10 is integer since, c,a has same digit in units place.

share|improve this answer

Your Answer

 
discard

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.