You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Farrukh Ahmad edited this page Dec 18, 2015
·
1 revision
Here program need to check simple number whether that is cubic sum or not
For example
153 = (1x1x1 ) + (5x5x5) + (3x3x3)
public class CubicSum {
public static void main(String[] args) {
int n = 371;
System.out.println(isCubicSum(n));
}
static boolean isCubicSum(int n){
int original = n;
int sum = 0;
while(n!=0){
int reminder = n % 10;
sum = sum + (reminder*reminder*reminder);
n = n / 10;
}
return original == sum;
}
}