Armstrong Number Program

package day1;

public class Amstrong {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    int no = 1634;
    int no1 = no;
    int armstrong = 0;
    while(no>0)
    {
        int rem= no%10;
        armstrong = armstrong + (rem*rem*rem*rem);
        no = no/10;
    }
    System.out.println(armstrong);
    if (armstrong == no1)
        System.out.println("armstrong");
    else 
        System.out.println("Not armstrong");

}

Enter fullscreen mode Exit fullscreen mode

}

out put = 1634
armstrong

原文链接:Armstrong Number Program

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
No matter how complicated your life is, you have to maintain your elegance.
不论生活如何复杂,总要保持自己的那一份优雅
评论 抢沙发

请登录后发表评论

    暂无评论内容