We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Number Theory
- Fibonacci LCM
- Discussions
Fibonacci LCM
Fibonacci LCM
Sort by
recency
|
8 Discussions
|
Please Login in order to post a comment
A few tips (no code) that helped me: 1) F_k devides F_l iff k devides l 2) gcd(F_k, F_l) = F_gcd(k,l) 3) Use that F_k = 1/2^k ( (1+1/sqrt(5))(1+sqrt(5))^(k-1) +(1-1/sqrt(5))(1-sqrt(5))^(k-1)) 4) Use Fermats little theorem i.e. a^p is congurent to a mod p if p is a prime to compute the multiplicative inverse of a mod p ( inv(a) = a^(p-2) mod p) 5) lcm(lcm(a_1,a_2,...,a_k),a_(k+1)) = (lcm(a_1,a_2,...,a_k) a_(k+1))/lcm(gcd(a_1,a_(k+1)),gcd(a_2,a_(k+1)),...,gcd(a_k,a_(k+1))
Python 3 solution
KOTLIN
Only one Test passed, can someone help with a good explainatory sudo code solution to this problem?
my code though
just matrix mulplication :))
The single example given is too trivial. The question require another with larger values so that the wrapped values from mod arithmetic are visible. This is where I was caught out and I feel cheated and the exercise was a waste of time. There is another general issue involving using mod arithmetic. Unless it is required for the Maths involved in the problem why create test cases whose outputs will overflow the native machine numerical limits? Why do this and then require mod arithmetic so that so wrapped nonsense value is required for the answer? I didnt think much of the editorial either.