Find value of ( n ^ 1 + n ^ 2 + n ^ 3 + n ^ 4 ) mod 5 for given n | finding the value of f ( n ) mod 5 for given n . ; function for f ( n ) mod 5 ; if n % 5 == 1 return 4 ; else return 0 ; driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; int fnMod ( int n ) { if ( n % 5 == 1 ) return 4 ; else return 0 ; } int main ( ) { int n = 10 ; cout << fnMod ( n ) << endl ; n = 11 ; cout << fnMod ( n ) << endl ; return 0 ; }