Code is copied!
Program To Print Niven Number JAVA
Write a Program to print whether the inputted number is Niven or not.
[A number is said to be Niven which is divisible by the sum of its digits.
Example: 126
Sum of its digits = 1 + 2 + 6 = 9 and 126 is divisible by 9.]
import java.util.*; class niven { public static void main(String args[]) { Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int temp =n,sum =0; while (n!=0) { sum = sum + (n%10); n=n/10; } System.out.println(sum); if(temp % sum == 0) { System.out.println("yes it is niven number"); } else { System.out.println("No it is not niven"); } } }