1.py
By: Anonymous5/26/202398 views Public Note
import math
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
def fun(num):
out_put = 0
if num > 0:
sqrt_num = math.sqrt(num)
if sqrt_num == int(sqrt_num):
fact = factorial(num)
if fact % 10 != 0:
out_put = fact
else:
str_fact = str(fact)
i = len(str_fact) - 1
zero_count = 0
while i >= 0 and str_fact[i] == '0':
zero_count = 1
i -= 1
if zero_count == 1:
if(len(str_fact)==3):
out_put = int(str_fact[:-1])
else:
out_put =int(str_fact[-4:-1])
else:
out_put = int(str_fact[(-1*(zero_count 3)):(-1*zero_count)])
else:
pass
else:
pass
return out_put
nums = input()
nums = nums.strip().split(',')
ls=[]
for i in nums:
tmp = fun(int(i))
if tmp !=0:
ls.append(str(tmp))
if ls!=[]:
print(','.join(ls))
else:
print(-1)