# Factors Program in Java

## Factor a number or algebraic expression that divides another number or expression evenly—i.e., with no remainder. For example, 3 and 6 are factors of 12 because 12 ÷ 3 = 4 exactly and 12 ÷ 6 = 2 exactly. The other factors of 12 are 1, 2, 4, 6 and 12. Factors of 12: 1, 2, 3, 4, 6, 12.

``````
import java.util.Scanner;

public class Factors
{
public static void main(String[] args)
{
int n;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number=");
n = sc.nextInt();
for (int i = 1; i <= n; i++)
{
if (n % i == 0)
{
System.out.println(i);
}
}
}
}
``````

#### Output:

```Enter number=6
1
2
3
6```
##### What is Factors Program?
Factor a number or algebraic expression that divides another number or expression evenly—i.e., with no remainder. For example, 3 and 6 are factors of 12 because 12 ÷ 3 = 4 exactly and 12 ÷ 6 = 2 exactly. The other factors of 12 are 1, 2, 4, 6 and 12.
Factors of 12: 1, 2, 3, 4, 6, 12.

##### What is Factors Program in Java?
Factor a number or algebraic expression that divides another number or expression evenly—i.e., with no remainder. For example, 3 and 6 are factors of 12 because 12 ÷ 3 = 4 exactly and 12 ÷ 6 = 2 exactly. The other factors of 12 are 1, 2, 4, 6 and 12.
Factors of 12: 1, 2, 3, 4, 6, 12.

b. tech. bca icse java java tutorials learn java mca programs
Recent Posts