forked from chennakrishnans/JAVA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactor.java
More file actions
35 lines (34 loc) · 758 Bytes
/
Copy pathfactor.java
File metadata and controls
35 lines (34 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.*;
import java.util.*;
class factor
{
public static void main(String args[])
{
try
{
Scanner sc=new Scanner(System.in);
int count=0,n,i;
System.out.println("Enter the number:");
n=sc.nextInt();
if(n<=0)
{
System.out.println("Enter valid number");
}
else
{
for(i=1;i<=n;i++)
{
if(n%i==0)
{
count++;
}
}
System.out.println("The number of factors:"+count);
}
}
catch(Exception e)
{
System.out.println("Enter only numbers");
}
}
}