def f(a,m): i = 1 n = 0 while n <= m: i = i * a n = n + 1 return i