Advertisement
j33vansh

Question 1 Peculiar Number Python Solution

Apr 21st, 2022
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try:
  2.     def sum_of_digit(n):
  3.         if (n == 0):
  4.             return 0
  5.         return (n % 10 + sum_of_digit(int(n / 10)))
  6.     t = int(input())
  7.     for i in range(t):
  8.         a, n = [int(a) for a in input().split()]
  9.         res = 0
  10.         k = 0
  11.         res = pow(a, n)
  12.         k = sum_of_digit(res)
  13.         print(k)
  14. except :
  15.     pass
Advertisement
RAW Paste Data Copied
Advertisement