SS&C Technologies Holdings QA automation may need to validate sequence calculations for large test inputs related to SS&C Advent Geneva processing. Given an index n and a positive modulus mod, return the nth Fibonacci number modulo mod without generating every preceding value.
The Fibonacci sequence is defined as F(0) = 0, F(1) = 1, and F(n) = F(n - 1) + F(n - 2) for n >= 2.
Implement fibonacci(n, mod):
n, a non-negative integer, and mod, a positive integer.F(n) % mod.n efficiently. Do not construct the complete sequence from 0 through n.def fibonacci(n, mod):