For example:
Input = 21
Nearest cubic root values for above digit are: 2 and 3
8 = 2*2*227 = 3*3*3
Among those values, 27 is nearer to 3, so it should be displayed as output.
For example:
Input = 21
Nearest cubic root values for above digit are: 2 and 3
8 = 2*2*227 = 3*3*3Among those values, 27 is nearer to 3, so it should be displayed as output.
I believe you are mixing up digit with number. Digits are just
0-9. Having said that, from the description you are giving I believe you want to compute the smallest difference between a given number (e.g. 21) and the cubed values of the closest two integer values to the cubic root of said number.So for 21 it would be:
21 ** (1/3) ~ 2,75232 ** 3 = 83 ** 3 = 2721| 8 - 21 | = 13| 27 - 21 | = 66which is obtained when cubing3so print3Here a Python script that will do exactly that.
Expected output (if entering 21)