- #1
shivajikobardan
- 674
- 54
Training on Playing with digits | Codewars
This is how I youtube'd and found a solution-:
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.
I want a more mathematical way of solving this problem. like using that given equation in code and finding a solution...I know we are already using it...but I want sth different.
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.
I want a more mathematical way of solving this problem. like using that given equation in code and finding a solution...I know we are already using it...but I want sth different.