def powersum(n, p, b=10):
 dlist = digitsrep(n, b)
 sum = 0
 for k in dlist:
  sum += (k ** p)
 return sum

def powersum ( n , p , b = 10 ) : dlist = digitsrep ( n , b ) sum = 0 for k in dlist : sum += ( k ** p ) return sum
return sum of digits of n raised to the power p .