Canna

Thursday, 27 September 2018

Positive Integer

  • Problem Description

    Program to find a Factors of a Positive Integer
  • Test Case 1

    Input (stdin)
    75
    
    
    Expected Output
    1 3 5 15 25 75
  • Test Case 2

    Input (stdin)
    16
    
    
    Expected Output
    1 2 4 8 16
  • Program
  • #include <stdio.h>
    int main()
    {
      int num,i;
      scanf("%d",&num);
      for(i=1;i<=num;i++)
      {
        if(num%i==0)
        printf("%d ",i);
      }
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.