Looking for some guidance on a C/JS program to find perfect cubes using the factorization method below. Any assistance is greatly appreciated.
- 3 * 3 * 3
- 3 * 3 * 3
- 3 * 3 * 3
JavaScript Code
var num=19683;
var arr=[];
for(i=2;i<num;i++){
if(num%i==0){
arr.push(i);
}
}
C Code
#include<stdio.h>
int main() {
int num=19683;
int a[20];
int j=0;
for(int i=2;i<num;i++){
if(num%i==0){
a[j]=i;
j++;
}
}
for(int i=0;i<j;i++){
printf(" %i", a[i]);
}
}
Result:
1,3,9,27,81,243,729,2187,6561