🔀⚡Beginner
Find All Factors of a Natural Number
Find all divisors
Factors of a number are all integers that divide it evenly (remainder = 0).
Program Code
factors.c
C
1#include <stdio.h>23int main() {4 int num;5 6 printf("Enter a number: ");7 scanf("%d", &num);8 9 printf("Factors of %d: ", num);10 11 for (int i = 1; i <= num; i++) {12 if (num % i == 0) {13 printf("%d ", i);14 }15 }16 printf("\n");17 18 return 0;19}Output
Enter a number: 24
Factors of 24: 1 2 3 4 6 8 12 24
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials