DEV Community

Saravanan Lakshmanan
Saravanan Lakshmanan

Posted on

JS/Python Looping program with if condition

Write a Program to find Two-Digit Divisors Where the Tens Digit Is Greater Than the Units Digit.

//JS
let n = 1092;

let i = 10;
while(i < 100){
    if(n % i == 0){
        let a = Math.floor(i / 10);
        let b = i % 10;
        if(a > b){
        console.log(i);
        }
    }
     i++;
}
Enter fullscreen mode Exit fullscreen mode
#Python
n = 1092

i = 10

while i < 100:
    if n % i == 0:
        a = i // 10
        b = i % 10

        if a > b:
            print(i)

    i += 1
Enter fullscreen mode Exit fullscreen mode

Output:

21
42
52
84
91
Enter fullscreen mode Exit fullscreen mode

Top comments (0)