Project Euler 225 - Tribonacci non-divisors
Project Euler 225 - Tribonacci non-divisors
Official link: https://projecteuler.net/problem=225
Thought Process
Thought Process
If the Tribonacci sequence modulo n is never equal to 0, then there are finitely many possibilities for any triple (Tn, Tn+1, Tn+2), which means that it will repeat at some point. After checking when each sequence repeats it seems to repeat (1, 1, 1) each time.
Using this the problem is quite simple, just generate the Tribonacci sequence modulo n and if you get a 0, then the sequence has a number divisible by n, if you see (1, 1, 1) again then the sequence will repeat and is hence never divisible by n
Interactive Code
Interactive Code
Enter a number (yourinput)
Code will output the yourinput-th odd number that does not divide any terms