Number of integers which has exactly 9 divisors

Write a program to count the Number of integers which has exactly 9 divisors.
C Program

#include <stdio.h>

int main()
{
    int n;
    printf("Enter a number : ");
    scanf("%d", &n);
    int diviorsCount = 0;
    for (int i = 1i <= ni++)
    {
        int count = 0;
        for (int j = 1j <= ij++)
        {
            if (i % j == 0)
            {
                count++;
            }
        }
        if (count == 9)
        {
            diviorsCount++;
        }
    }
    printf("Number of integers with exactly 9 divisors til %d is %d"ndiviorsCount);

    return 0;
}
Input:

Enter a number : 100

Output:

Number of integers with exactly 9 divisors til 100 is 2   


No comments:

Post a Comment