Java Assignment 4: find all the numbers from 100 to 999 between daffodils

Lx Package Penalty for;
/ ** Classic T questions:

  • Find all the numbers from 100 to 999 between daffodils

  • Narcissistic number: 3 power on the power of the single digits + 3 + 3 power on the hundreds digit on the ten-digit numbers themselves =

  • 如123=1³+2³+3³;
    /
    public class ForTest {
    public static void main(String[] args) {
    //设置循环
    for (int num = 100; num <= 999; num++) {
    int ge = num % 10;
    int shi = num%100/10;//num/10%10;如125/10=12%10=2
    int bai = num/100;
    int result = ge
    gege+shishishi+baibai*bai;
    if (result==num){
    System.out.println(num);

            }
    }
    

    }
    }
    Here Insert Picture Description

Published 154 original articles · won praise 6 · views 5500

Guess you like

Origin blog.csdn.net/weixin_45339692/article/details/104864053