Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. Brute Force O(N): store three variables, t1, t2, index. While an iterable i is smaller than index, change t2 to t1+t2 and t1 to the original value of t2. Return t2 at the end.
  2.  
  3. A Pissano period is a period that occurs when you modulo all terms the fibonacci sequence. This is given by a function pi(x), where x is the modulo. However, it is not easy to calculate pi(1000000007) because it is too large.
  4.  
  5. Optimized Brute Force: we can optimize the O(N) brute force by noting that if ever in our sequence that t1 = 0 and t2 = 1 and i != 1, this is the beginning of a new period. Therefore, we can modulo the remaining by the length of the period.
  6.  
  7. By Lagrange's theorem and Fermat's little theorem, we can eventually prove that for every prime N where N is congruent to 2 mod 5, the N+1th fibonacci term is congruent to 0 mod N.
  8.  
  9. Number Theory Method: at the start of the program, modulo the index by N+1 since the N+1th term will have t1 = 0 and t2 = 1.
  10.  
  11. Theoretically, the above solution should work. For some unknown reason, it doesn't.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement