How to Find Divisors in Python, Java, and JavaScript

What is a Divisor?

A divisor is a number that divides another number completely without leaving a remainder.

For example:
Divisors of 10 → 1, 2, 5, 10

Flowchart Logic

The flowchart follows these steps:

  1. Start the program
  2. Initialize the number (Num = 100)
  3. Set divisor value (Div = 2)
  4. Check if Div is less than Num
  5. If true:
  6. Check if Num is divisible by Div
  7. If yes, print the divisor
  8. Increase Div by 1
  9. Repeat the process
  10. Stop when condition fails

Python Code

num = 100
div = 2

while div < num:
    if num % div == 0:
        print(div)
    div = div + 1

Java Code

public class Divisors {
    public static void main(String[] args) {
        int num = 100;
        int div = 2;

        while (div < num) {
            if (num % div == 0) {
                System.out.println(div);
            }
            div = div + 1;
        }
    }
}

JavaScript Code

let num = 100;
let div = 2;

while (div < num) {
    if (num % div === 0) {
        console.log(div);
    }
    div = div + 1;
}

Output


2
4
5
10
20
25
50