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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #30: Digit Nth powers
  4. Discussions

Project Euler #30: Digit Nth powers

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • George_Emmanuel
    2 years ago+ 0 comments
    N = int(input())
    c = []
    for i in range(2, 10000000):
        cnt = 0
        for j in str(i):
            cnt += int(j) ** N
        if cnt == i:
            c.append(cnt)
    print(c)
    

    if you want to check for all numbers you can check the numbers in the list then you could simply check their sum for any N value. Just change the line "Print(c)" to print(sum(c)) Be sure to check this in your own ide as here it would give a TLE

    2|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy