π Problem Solving from Codeforces using C language
This is a problem-solving post from Codeforces. Below is the problem with a short explanation and its solution.
This example is solved using C language.
π§© Main Problem:Given a numberΒ N. Print all theΒ divisorsΒ ofΒ NΒ in ascending order.
π Problem Link: Codeforces Problem
π‘ Solution:
#include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i =1; i<=n; i++)
{
if (n%i==0) // here, input n is checking by all numbers of "i" is that divisible or not
{
printf("%d\n", i);
}
}
return 0;
}
β This solution reads an integers “n” from user and then find the divisors of “n” in ascending order.
π Input:
6
π Output:
1
2
3
6
π Input:
7
π Output:
1
7
π Find Similar Problems from Codeforcesβ Click Here
π€ More Problem Solving β Click Here
π Learn C Programming β Click Here