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.
- All Contests
- ProjectEuler+
- Project Euler #225: Tribonacci non-divisors
Project Euler #225: Tribonacci non-divisors
Project Euler #225: Tribonacci non-divisors
This problem is a programming version of Problem 225 from projecteuler.net
The sequence , , , , , , , , , , , , , ... is defined by and .
It can be shown that does not divide any terms of this sequence. In fact, is the first odd number with this property.
Given , and , find the th odd number that does not divide any terms of the above sequence.
Input Format
First and only line of each test file contains four integers separated by single spaces: , , and .
Constraints
- are odd
Output Format
Print exactly one number that is the answer to the problem.
Sample Input 0
1 1 1 1
Sample Output 0
27
Sample Input 1
1 29 19 131
Sample Output 1
2019
Explanation 1
Happy New Year!