Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def expo(a, b):
- res = a**b
- str_res = f"{a}^{b} = {res} => "
- L1 = list(str(res))
- while len(L1) != 1:
- sumd = 0
- for i in range(len(L1)):
- if i == 0:
- str_res += f"{L1[i]}"
- else:
- str_res += f"+{L1[i]}"
- sumd += int(L1[i])
- else:
- str_res += " = "
- L1 = list(str(sumd))
- if len(L1) == 1:
- str_res += f"{sumd}"
- break
- else:
- str_res += f"{sumd} => "
- print(str_res)
- # Call the Function with 2 arguments
- expo(8,8)
Advertisement
Add Comment
Please, Sign In to add comment