# Thread: factor of integers trouble

1. ## factor of integers trouble

so basically im writing a program that output the positive factors of a integer that a user inputs....for the life of me i cant figure out how to get the program to output the positive integers i believe i need a mod but every way i tried to do it it just wont work... this is what i have so far. i tried user for statements and if statements but it just isnt output the correct numbers any help would be amazing! thanks.

Code:
```#include <stdio.h>

int main () {
int integer;

//This will take in the input of the integer
do{
printf("Enter a positive integer greater than one.\n");
scanf("%d", &integer);

//This will print the appropriate invalid number message
if (integer<=1)
printf("Sorry, that input is not valid.\n");
}
//This will execute as soon as integer is greater than 1
while (integer<2);

system("PAUSE");
return 0;
}```

2. What are you expecting it to output ?

There isn't a single output statement past your input loop.

3. there isnt i know because i cant figure out a exact statement that will output the factors of whatever the user inputs for example if he inputs 10 itll print out 1,2,5,10 thats all i want it to do for now eventually after i get that down i want it to print the number of factors the number has the sum of the factors of the integer and the product of the factors, but i need to get the initial factors first i want to try the other stuff on my own before i pray for help lol. thanks!

4. ok got it to print out proper outputs awesome ya! cool now where i start getting more irritated haha so check it out:

now what im trying to do is get it to produce a count of the total number of factors any helpful hints ive been running through pages of sites trying to find anything that may help but nothing any help would be amazing even if its just something i should use

Code:
```#include <stdio.h>

int main () {
int integer, factors, number_factors, sum, product;

//This will take in the input of the integer
do{
printf("Enter a positive integer greater than one.\n");
scanf("%d", &integer);

//This will print the appropriate invalid number message
if (integer<=1)
printf("Sorry, that input is not valid.\n");
}
//This will execute as soon as integer is greater than 1
while (integer<2);

//This will print out the factors
for(factors=1;factors<=integer;factors++){
if(integer % factors == 0)
printf("%d ",factors);
}
//This will go to the next line
printf("\n");

system("PAUSE");
return 0;
}```

5. Code:
```int n = 0;
for(factors=1;factors<=integer;factors++){
if(integer &#37; factors == 0) {
printf("%d ",factors);
n++;
}
}
printf ("There are %d factors", n);```
QuantumPete