Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sumOfPowers(n, divisor)
- x = 1
- sum = 0
- y = 0
- max_power = 0
- while x <= n
- while y <= x
- if (divisor ** y) == 1 then
- max_power = 0
- else
- if x % (divisor ** y) == 0 then
- max_power = y
- end
- end
- y = y + 1
- end
- sum = sum + max_power
- x = x + 1
- y = 0
- max_power = 0
- end
- return sum
- end
Advertisement
Add Comment
Please, Sign In to add comment