Java Program to find All the Divisors ( Factors ) of a Number

preview_player
Показать описание
In this Java Programming Video Tutorial you will learn to write a program to find all the Divisors ( Factors ) of a Number entered by the user.

In this Program written in Java Language first we will take the number from the user and we store it in a variable. After that we start dividing the number from 2 up to number / 2.
That's because we already know that the number 1 and the number itself are the divisors and other possible range of values that can be the divisors are from 2 to number/2.
When we divide the number lets say x by another lets say y and if we get remainder as 0 it means that y is the divisor of x.
Here we will display all the divisors of the number.

Get the Source Code of this tutorial at

our Social Media Pages

#JavaProgramming #ExampleProgram #JavaExamplePrograms
Рекомендации по теме
Комментарии
Автор

I think that the second version of the for loop is clearer because it is clear that the factors are 1 and the number itself.

stanislavdimitrov
welcome to shbcf.ru