# Finding number of integers which has exactly X divisors

## Java program to find Number of integers which has exactly x divisors:

Our Aim is to find the Number of integers which has exactly X divisors using Java programming language.

In This program the user gives  a range and the number of divisors(say N), and divisors of every number in between the range are counted and compared with N.

At last the total number of integers are counted which have N number of divisors. #### Implementation:

• Start
• Iterate all numbers till n
• Count the numbers that have exactly 9 divisors
• Iterate till n
•  Check if n is divisible by i
• Increase value of count
• Print count
• Stop

#### Code In Java:

import java.io.*;
import java.util.Scanner;
import java.util.*;
public class Prepinsta
{
static int divisors(int num)
{
int count = 0;
for (int i = 1; i <= num; i++)
{
if (num % i == 0)
count = count + 1;
}
return count;
}

static void check(int n)
{
int c = 0;
for (int i = 1; i <= n; i++)
{
if (divisors(i) == 9)
{
System.out.print(i);
System.out.print(” “);
c = c + 1;
}
}
System.out.print(“\n\nTotal number of divisors= ” + c);

}

public static void main (String[] args)
{
int n;
System.out.print(“\nEnter the number of your choice  : “);
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
System.out.print(“\n Number which has exactly 9 divisors are : “);
check(n);
}
}

`Output:Enter the number of your choice :100The number which has exactly 9 divisors36 100Total number of divisors =2`