0

Hey people... I have one problem...

Find how many total cubes are there in the range from A to B, inclusive.

An integer Y is total cube if it can be expressed as: Y = X*X*X, where X is also integer.

The first total cubes are: 1, 8, 27, 64 ...

Input parameters:

A, B - integer, the lower and the upper bounds.

Constraints:

A, B will have between 1 and 1000000 inclusive.

A will be less or equal to B (A<=B)

Return value:

int, the number of total cubes in the given range.

Class Name:

TotalCubes

Method signature:

public int howMany(int A, int B)

...and now... my class code is:

```
public int howMany(int A, int B) {
if(A==B) { return 1; }
int totCub = 0;
for(double i=A; i<=B; i++) {
// I try and with „int i...“
if((Math.pow(i, 1.0/3.0)%10)==0) { totCub++; }
}
return totCub;
}
```

...and the return value always is 0 (zero), why ? :(

Thanks...

*Edited 7 Years Ago by Krstevski*: n/a