Dain1234 / Java-Programming

0 stars 0 forks source link

Armstrong number #1

Open Dain1234 opened 1 year ago

Dain1234 commented 1 year ago

package com.dain.logics;

import java.util.Scanner;

public class Armstrong { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the number to check:"); int n = sc.nextInt(); int num1 = n; int arm = 0; while (n != 0) {

        int rem = n % 10;
        arm = arm + (rem * rem * rem);
        n = n / 10;

    }
    if (num1 == arm) {
        System.out.println("it is an armstrong number");
    } else
        System.out.println("not an armstrong");

}

}

jayendra541 commented 9 months ago

What's the issue?