Dain1234 / Java-Programming

0 stars 0 forks source link

Composite numbers #4

Open Dain1234 opened 1 year ago

Dain1234 commented 1 year ago

package com.dain.logics;

import java.util.Scanner;

public class compositenumbers { public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    System.out.println("Enter the first limit:");
    int a = sc.nextInt();
    System.out.println("Enter the second limit:");
    int b = sc.nextInt();
    for (int i = a + 1; i <= b - 1; i++) {
        int c = 0;
        for (int j = 1; j <= 100; j++) {
            if (i % j == 0) {
                c++;

            }

        }
        if (c > 2) {
            System.out.println(i);
        }

    }

}

}