Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- have a holder
- have a n to count the values whose cube is within bounds
- while loop to itterate through
- keep adding cubes till number is reached if number is excat as m return n else return -1
- while loop so base case of 1
- '''
- import math
- def find_nb(m):
- holder = 1
- n = 2
- if m == 1 ** 3:
- return 1
- else:
- while(holder < m):
- holder = holder + (n ** 3)
- if holder == m:
- print(holder)
- return n
- else:
- n += 1
- return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement