URI Online Judge Solution 1157 Divisors I Using C, Python Programming Language.
Read an integer N and compute all its divisors.
Input
The input file contains an integer value.
Output
Write all positive divisors of N, one value per line.
Input Sample | Output Sample |
6 | 1 |
Solution Using C:
#include <stdio.h>
int main() {
int n,i;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
if(n%i == 0)
printf("%d\n",i);
}
return 0;
}
Comments
Post a Comment