| about | help | code help+videos | done | prefs |
powersum
Given k and n, return a list of all the positive integers less than n such that the sum of the kth powers of their individual digits equals the integer itself. For example, with k=3 and n=1000, one of the numbers we would return in the list would be 371, because 371 = 3^3 +7^3 + 1^3 = 27 + 343 + 1. (This problem inspired by Project Euler.) powersum(1, 10) → [1, 2, 3, 4, 5, 6, 7, 8, 9] powersum(2, 100) → [1] powersum(3, 1000) → [1, 153, 370, 371, 407] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300 Post-solution available
Copyright Nick Parlante 2017 - privacy