shivajikobardan
Legendary Coder
Training on Playing with digits
Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.
www.codewars.com
playing with digits codewar problem-looking for alternative way to solve this problem-mathematical way to solve this problem-:
This is how I youtube'd and found a solution-:
Code:
n=89
p=1
my_sum=0
for num in str(n):
my_sum=my_sum+(int(num))**p
p=p+1
if(my_sum%n==0):
print(int(my_sum/n))
else:
print(-1)
What is another way to solve this problem? I prefer no code solutions with flowcharts/algorithms rather than writing codes so that I can try writing codes on my own. But I of course won't mind code with comments tbh.