# CPP Program Find the Cube Free Number – Number Theory

• A cube free number is a number whose none of the divisors is a cube number (A cube number is a cube of an integer like 8 (2 * 2 * 2), 27 (3 * 3 * 3) ). So cube free numbers are 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18 etc (we will consider 1 as cube free). 8, 16, 24, 27, 32, etc are not cube-free numbers. So the position of 1 among the cube-free numbers is 1, the position of 2 is 2, 3 is 3 and the position of 10 is 9.
• Given a positive number you have to say if it’s a cube-free number and if yes then tell its position among cube-free numbers.

Input:

The first line of the test case will be the number of test cases T (1 <= T <= 100000). Then T lines follow. On each line you will find a integer number n (1 <= n <= 1000000).

Output:

For each input line, print a line containing “Case I: ”, where I am the test case number. Then if it is not a cube-free number then print “Not Cube Free”. Otherwise, print its position among the cube-free numbers.

Sample Input:

```10
1
2
3
4
5
6
7
8
9
10```

Sample Output:

```Case 1: 1
Case 2: 2
Case 3: 3
Case 4: 4
Case 5: 5
Case 6: 6
Case 7: 7
Case 8: Not Cube Free
Case 9: 8
Case 10: 9```

## Code:

```.wp-block-code {
border: 0;
}

.wp-block-code > span {
display: block;
overflow: auto;
}

.shcb-language {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
position: absolute;
width: 1px;
word-wrap: normal;
word-break: normal;
}

.hljs {
box-sizing: border-box;
}

.hljs.shcb-code-table {
display: table;
width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
color: inherit;
display: table-row;
width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
border-spacing: 0;
counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
}

.hljs.shcb-line-numbers .shcb-loc::before {
border-right: 1px solid #ddd;
content: counter(line);
display: table-cell;
text-align: right;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: 1%;
}
```#include<iostream>
using namespace std;
void Sieve_Array_Filler(int*arr)
{
for(int i=0; i<1000001; i++)
{
arr[i]=0;
}
arr=1;
for(int i=2; i<=100; i++)
{
int current_cubic_number=i*i*i;
for(int j=1; current_cubic_number*j<1000001;j++)
{
arr[current_cubic_number*j]=-1;
}
}
int k=1;
for(int i=1; i<=1000000; i++)
{
if(arr[i]!=-1)
{
arr[i]=k;
k++;
}
}
}
int main()
{
int t;
cin>>t;
int *arr=new int ;
Sieve_Array_Filler(arr);
for(int test_case=1; test_case<=t; test_case++)
{
int n;
cin>>n;
if(arr[n]!=-1)
{
cout<<"Case "<<test_case<<": "<<arr[n]<<endl;
}
else
{
cout<<"Case "<<test_case<<": "<<"Not Cube Free"<<endl;
}
}
}
```Code language: C++ (cpp)```