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 #167: Investigating Ulam sequences
Project Euler #167: Investigating Ulam sequences
Project Euler #167: Investigating Ulam sequences
Contest ends in
This problem is a programming version of Problem 167 from projecteuler.net
For two positive integers and , the Ulam sequence is defined by , and for , is the smallest integer greater than which can be written in exactly one way as the sum of two distinct previous members of .
For example, the sequence begins with
does not belong to it because has two representations as the sum of two previous members, likewise .
Find
Input Format
Two space-separated integers and are given on first line.
Constraints
Output Format
Print one integer which is the answer to the problem.
Sample Input 0
2 10
Sample Output 0
23
Explanation 0
Beginning of is