Factors of number

    0

    0

    Giovanny Gongora

    Codiga's C Recipes

    Find all the positive factors of an integer entered by the user.

    #include <stdio.h>
    
    int factors() {
      int num, i;
      printf("Enter a positive integer: ");
      scanf("%d", &num);
      printf("Factors of %d are: ", num);
      for (i = 1; i <= num; ++i) {
        if (num % i == 0) {
          printf("%d ", i);
        }
      }
      return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.