a program that displays the divisors of number

/*Write a program that displays the divisors of number, and then it prints the result*/


class Divisors
{
int n;
void getData() throws IOException
{
DataInputStream d=new DataInputStream(System.in);

System.out.print("\n\tEnter The No:");
n=Integer.parseInt(d.readLine());
}
void printDivisor()
{
System.out.println("\nDivisors Of "+n+" :"+"\n");
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
System.out.print(i+"\t");
}
}
}

}
class seventh
{
public static void main(String args[]) throws java.io.IOException
{
Divisors d=new Divisors();
d.getData();
d.printDivisor();
}
}

0 comments:

Post a Comment