1

# What a the algorithm to find wheather a number is prefect cube or not?

Mon 18 Nov, 2013 01:14 pm
I want to know the algorithm to find if a number is perfect cube or not , like 27 is a perfect cube 28 is not.
• Topic Stats
• Top Replies
Type: Question • Score: 1 • Views: 1,094 • Replies: 2
No top replies

markr

1
Mon 18 Nov, 2013 01:48 pm
@Kathleenortan,
28 is just plain perfect.

Are you looking for something you'd implement with a programming language, or is this just a mathematical exercise?

If the former, and if you have a function that provides floating point cube roots, then something like this should do the trick:
y = round(cuberoot(x))
if (y*y*y == x) then x is a perfect cube

If the latter, determine the unique prime factorization of the absolute value of the number. If the exponents of all of the prime factors are multiples of 3, then the number is a cube. The number is also a cube if the number is zero or one.
0 Replies

raprap

1
Mon 18 Nov, 2013 06:13 pm
@Kathleenortan,
You can also use logarithms. If x is the number, then find the logarithm of x and divide it by 3. Then take the antilog of that number. If the resulting number is an integer it is a perfect cube.

Effectively I'm doing the same thing markr is recommending--it's just this is a calculator algorithm.

Rap
0 Replies

### Related Topics

Amount of Time - Question by Randy Dandy
logical number sequence riddle - Question by feather
Calc help needed - Question by mjborowsky
HELP! The Product and Quotient Rules - Question by charsha
STRAIGHT LINES - Question by iqrasarguru
Possible Proof of the ABC Conjecture - Discussion by oralloy
Help with a simple math problem? - Question by Anonymous1234567890
How do I do this on a ti 84 calculator? - Question by Anonymous1234567890

1. Forums
2. » What a the algorithm to find wheather a number is prefect cube or not?