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.

I have the following expression for $n>3$:

$$\frac{5\cdot(n-1)\cdot[8\cdot\operatorname{Luc}(n) + 5\cdot\operatorname{Luc}(n-1)] + [4\cdot\operatorname{Luc}(n-1) - 8\cdot\operatorname{Luc}(n)]}{25}$$

where $\operatorname{Luc}(n)$ gives the $n$th term in the Lucas sequence

$$ 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, \dots $$starting from index $0$.

How do I reduce/rearrange it to remove the $25$ from the denominator? I need this so that I can take the modulus of the entire equation, without first doing any division. (The number in the numerator exceeds $2^{64}$, and I cannot store it in the memory)

share|improve this question
1  
If $25$ is coprime to $p$ (as in $\pmod{p}$), then $a/b \pmod{p} \equiv (a \pmod{p})/(b \pmod{p}) \pmod{p}$. Does that help? –  Karolis Juodelė Sep 7 '12 at 19:55
    
Elements of the sequence $f_n = \frac{n-1}{5} \left( 8 L_{n} + 5 L_{n-1}\right) + \frac{4}{25} \left( 2 L_n - L_{n-1} \right)$ are not integral. For instance, $f_2 = \frac{33}{5}$. Are you expecting to end-up with $5$ in the denominator? –  Sasha Sep 7 '12 at 19:56
    
For $n=9$, the result is $\dfrac{6828}{5}$. Is there possibly a typo? –  Kris Williams Sep 7 '12 at 19:59
    
@KarolisJuodelė : the value of p = (10^9 + 7). Which is Coprime to 25. But How will this help ? if a = 150 , b = 25 and p =27 (p is coprime to b) , but (a/b)%p != ((a%p)/(b%p))%p . Or am I understanding the concept wrong ? –  Kyuubi Sep 7 '12 at 20:07
    
@Sasha : The values are only for n>3 –  Kyuubi Sep 7 '12 at 20:07
show 3 more comments

1 Answer

up vote 1 down vote accepted

If you want to get the answer mod n, dividing by 25 is the same as multiply by the inverse of 25 mod n, which you can compute using extended GCD (http://en.wikipedia.org/wiki/Modular_multiplicative_inverse).

This requires that gcd(25,n)=1. If that is not the case, you're in trouble.

share|improve this answer
add comment

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.