Video courses for company/skill based Preparation
(Check all courses)Get Prime Video
Purchase mock tests for company/skill building
(Check all mocks)Get Prime mock
C program to find number of integers which has exactly x divisors
Number of integers which has exactly x divisors
Numbers dividing with self or 1 are called prime numbers but numbers having multiple divisors are called composite numbers. In this python program, we will find the numbers with the exact number of divisors defined by the user. The divisor of a number is defined, when we divide a number1 by other number let number2 and gives remainder zero, so the number2 will be considered as the divisor of the number1. We will find the number of the divisor of the numbers and print them along with the count of numbers.
- Step 1:- Start.
- Step 2:- Take user inputs like Number and Divisors.
- Step 3:- Initialize a count variable with zero value.
- Step 4:-Run a for loop with a range from 1 to Number+1.
- Step 5:- Initialize another count variable with zero.
- Step 6:- Run other for loop ranging from 1 to iterator of 1st for loop+1.
- Step 7:- Check for complete division conditions and if TRUE increment count2 by 1.
- Step 8:- Come out of for loop and check if count2 is equal to Divisor.
- Step 9:- If TRUE increment count1 by 1 and print the number with exact divisors.
- Step 10:- Print count1.
- Step 11:- End.
int number, divisor;
int i, j;
printf("enter range of number : ");
printf("enter exact number of divisor : ");
int count1 = 0, count2 = 0;
for(i=1; i<number+1; i++)
count2 = 0;
for(j=1; j<i+1; j++)
printf("%d ", i);
Enter range of number :30
Enter exact number of divisors :3
4 9 25