function that manually calculates n ^ n and then removes digits until k digits remain
unsigned long long firstkdigits ( int n , int k ) { unsigned long long product = 1 ; for ( int i = 0 ; i < n ; i ++ ) product *= n ;