Cicadas are natural mathematicians. In order to avoid their natural predators (in this case, the wasp), they emerge from hibernation in "a prime number" of years. For example, if the emergence period of a wasp is every
years, selecting 4 or 6 or even 9 years emergence period for the cicadas, means that their population would be wiped out in a few years. But, by selecting a prime emergence period, say
years, they are assured not to meet their predators for a very long time. In this case, if cicadas and wasps emerged the same time today, it would take another
years for them to again see each other.
In a theoretical environment, a particular species of cicadas selects to emerge every
(n-th Fibonacci number) days, while the predator wasps selects emergence period of
(m-th Fibonacci number) days. Given the values of n and m, and assuming that the insects emerge at the same time, today, in how many days will they again emerge together.
For example, if the cicadas selected
, and the wasps chose
, they will emerge at the same time again in
days.
NOTE: You are given:
and
. Since the answer can be a huge number, please present your answer "modulo
".
Solution Stats
Problem Comments
6 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers4
Suggested Problems
-
244 Solvers
-
Sort numbers by outside digits
161 Solvers
-
240 Solvers
-
1254 Solvers
-
24 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I am getting 51840212 for test 7 instead of 90928381.
Hi Tim,
I've updated test 7. Please try again. Thanks.
Thanks, I would try, but I am using "BigInteger" and "for" and will therefore fail test 10.
Hi Tim, please consider that modulus of Fibonacci numbers are periodic...
This should be part of the problem statement (test case 10):
Not Allowed in solution:
'persistent' 'global' 'BigInteger' 'java'
(OK so far, but also)
'if' 'for' 'switch' 'while' 'try'
Hi Gee, thanks for the comment. However, I don't think there is need to include it in the problem statement coz players can already clearly see the blocked functions in test 10.