- #1
shivajikobardan
- 674
- 54
- Homework Statement
- need alternative way to solve the problem
- Relevant Equations
- none
https://www.codewars.com/kata/5552101f47fc5178b1000050/train/python
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-:
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.
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.