*}
codea teams

Factor Integer



Factor an integer number

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char* argv[])
{
    if (argc < 2)
    {
        fprintf(stderr, "Invalid number to factor\n\n");
        exit(-1);
    }

    int x, N;
    int input;

    input = atoi(argv[1]);

    for (x = 1; x<=(input/x);x++)
    {
        if (input % x == 0)  printf("%d %d ",x, input/x);
    }
    printf("\n");
}