Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

HARSHAD NUMBER

import java.util.*;

class harshad

void niven(int mn)

int sum = 0;

int r;

int temp = mn;

while(temp>0)

r = temp%10;

sum = sum+r;

temp = temp/10;

if(mn%sum==0)

System.out.println("The number is niven");

else

System.out.println("The number is not niven");

public static void main()

{
Scanner scn = new Scanner(System.in);

System.out.println("Enter the number");

int fn = scn.nextInt();

harshad rsh = new harshad();

rsh.niven(fn);

You might also like