We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #30: Digit Nth powers
Project Euler #30: Digit Nth powers
Sort by
recency
|
53 Discussions
|
Please Login in order to post a comment
import java.io.; import java.util.;
public class Solution {
}
//C# using System;
class Program { static int PowerSum(int num, int power) { int sum = 0; int temp = num;
}
This code workes well using python 3
for n=5, it also has numbers ranging from 1000 to 1000000, so the solution in python will be
n=int(input().strip()) sum_=0 if n==5: sum_ = sum([i for i in range(10**(n-2), 10**(n+1)) if sum(int(digit)n for digit in str(i)) == i]) print(sum_) else: sum_ = sum([i for i in range(10(n-1), 10**(n)) if sum(int(digit)**n for digit in str(i)) == i]) print(sum_)