Fibonacci modulo p | C # program to find minimal 0 Fibonacci for a prime number p ; Function that returns position of first Fibonacci number whose modulo p is 0 ; add previous two remainders and then take its modulo p . ; Driver program
using System ; class GFG { static int findMinZero ( int p ) { int first = 1 , second = 1 ; int number = 2 , next = 1 ; while ( next > 0 ) { next = ( first + second ) % p ; first = second ; second = next ; number ++ ; } return number ; } public static void Main ( ) { int p = 7 ; Console . WriteLine ( " Minimal ▁ zero ▁ " + " is ▁ : " + findMinZero ( p ) ) ; } }