Computer Science, asked by akriti1444, 8 months ago

write a program in java to input a number and print the factors of each digit of the number.​

Answers

Answered by 5827kshitij
0

In java you can use println() in bracket you just write what you want to and it will print on the screen of your programme

Hope you like it !!!

Plz mark me brainliest

Answered by anishaverma5591
5

Answer:

To understand this example, you should have the knowledge of the following Java programming topics:

Java for Loop

Java if, if...else Statement

Example: Factors of a Positive Integer

public class Factors {

public static void main(String[] args) {

int number = 60;

System.out.print("Factors of " + number + " are: ");

for(int i = 1; i <= number; ++i) {

if (number % i == 0) {

System.out.print(i + " ");

}

}

}

}

Output

Factors of 60 are: 1 2 3 4 5 6 10 12 15 20 30 60

In the above program, number whose factors are to be found is stored in the variable number (60).

The for loop is iterated until i <= number is false. In each iteration, whether number is exactly divisible by i is checked (condition for i to be the factor of number) and the value of i is incremented by 1.

Explanation:

I think it is helpful so don't forget to follow mee

Similar questions