a. 456533
b.
10. Check whether 24x’y2 is a perfect cube or not.
If not, find the smallest number by which it
should be divided to make it a perfect cube.
Also, find the cube root of the perfect cube
number so obtained:
numbers
Attachments:
Answers
Answered by
2
a) ∛456533= 77
b) ∛132651 = 51
10) Factors of 24x³y³= 3*2*2*2*x*x*x*y*y*y
Paired numbers = 2*x*y {3 will go on other side as it is unpaired}
=24/3= 8
= ∛8 = 2
So 3 is the smallest number which should be divided to get a perfect cube and 8 is the perfect cube whose cube root is 2.
Answered by
3
Answer:
If depends on how big the number becomes.
If the number can become quite big, maybe the fastest method is to simply take the cuberoot and check if the result is an integer.
Taking the cuberoot can be done by converting to floating point and raising to the power 1/3.
unsigned long n,n2;
float d,cuberoot;
bool perfectcube;
d = (float) n; // converting from integer to floating point
cuberoot = exp(log(d)/3.0); // taking the cuberoot using x^y = exp(y*log(x))
n2 = floor(cuberoot + 0.001); // rounding down the result
if (n2*n2*n2 == n) perfectcube = true; else perfectcube = false;
In number of operations, this must be among the best methods. I don’t know if it is also the fastest method as taking exp() and log() takes time. Maybe we can do better by counting the number of digits and guessing. If an integer has more than 3 digits, then the cuberoot has more than 1 digit, etc … An algorithm for this would be
unsigned long n2 = n;
int counter = 0;
int nrdigits;
while (n2 > 0)
n2 /= 10;
counter++:
nrdigits = (counter-1) / 3 + 1; // nrdigits is the number of digits of the cuberoot
if nrdigits is not too big we can simply try by binary search which has time complexity O(log(n)) and is very fast and like this we do not need slow floating point operations like log() and exp() but only integer multiplications.
We can also take a number theoretical approach and note that the last digit of our number n indicates the last digit of the cuberoot (if it is a perfect cube) :
0 -> 0
1 -> 1
2 -> 8
3 -> 7
4 -> 4
5 -> 5
6 -> 6
7 -> 3
8 -> 2
9 -> 9
The first digits say also a lot about the first digit of our cuberoot, always under the assumption that it is a perfect cube, which we must always
Similar questions