Java method for calculating the number of daffodils in natural Numbers

  • 2020-04-01 03:06:13
  • OfStack

The core code



static void getNums(int n,int m){
for(int i=m;i<=n;i++){
int ge,shi,bai;
double shui;
bai=i/100;
shi=i%100/10;
ge=i%10;
shui=Math.pow(bai, 3)+Math.pow(shi, 3)+Math.pow(ge, 3);
if(i==shui)
System.out.println(i);
}
}


Related articles: