# Thread: Can someone help me out here?

1. ## Can someone help me out here?

At least show me the logic on how to solve the math problem parts. I will put it into program if you just explain to me how to get the factors, tell how many, find the sum, and find the product.

Hi, im kinda new to using loops in my programming. I'm still a little rusty. could someone hep me out a little on this problem?
I sure could use some quick help from you guys. You've always been there in the past. Thanks so much.

I need a program that will prompt the user for a single positive integer greater than 1. If the user does not enter a valid integer, then the program should continue to reprompt the user for a value until a valid integer is entered. Once the integer is read in, the program will print out the following information about the integer:

1) A list of each of the positive factors of the given integer.
2) The number of factors the given integer has.
3) The sum of the factors of the integer.
4) The product of the factors of the integer.

An example output would be :

Enter a positive integer greater than one.
12

Here is a list of the positive factors of 12:
1 2 3 4 6 12

The number of positive factors of 12 is 6.
The sum of the positive factors of 12 is 28.
The product of the positive factors of 12 is 1728.

thanks so much guys.

At least show me the logic on how to solve the math problem parts. I will put it into program if you just explain to me how to get the factors, tell how many, find the sum, and find the product.

Ive looked at that stuff please can someone help me. It shouldnt be that hard for you guys. I'm new and need some help. I'm sorry. there was a point when everyone was still a beginner. And I appreciate all the help you guys give me. Now please help out a fellow programmer and assist in this newbie program. I would do the same for you guys. Thanks so much for being here to help me.

3. hint: take a look at what the % operator does...

>>At least show me the logic on how to solve the math problem parts.
>>how to get the factors, tell how many, find the sum, and find the product.
Errr, what? You want help on how to tell "how many there are" and how to "find the sum"? That's some pretty basic maths experience you're missing

5. ## Thanks anyway

I know how to count how many there are. I just need to know how to find out what they are and print them to the screen. Thats probably all the help i need. And also how to tell the computer to print how many there are. Please help me out guys.
Im not asking you to write the program. Im new to the problem solving thing.

heres what i have so far. All it does is print a bunch of threes forever.

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

int main()  {

int integer, j;
printf("Enter a positive integer greater than one.\n");

while(integer>=2) {
// Find and list positive factors.
for(j = 2; j < (integer / 2); j++)
{
if ((integer % j) == 0) {
printf("%d ", j);
}
}
}
}```

6. Factoring help.

7. ## Honestly

Please, i know how to find factors. I just dont know how to put them into the c language. Please assist me in this.

please help me on this guys. It is very hard to understand what to do as a newbie. You can probably write some code for this problem in like 2 minutes. Please help. please help me out with finding those four things in the problem. Ill get the hang of this stuff soon.

i have this so far :

Code:
```int main()

{

int LoopCount = 0;
int integer ;

printf("Enter a positive integer greater than one.\n";
scanf("%d", integer);

for (int j=1; j <= LoopCount; j++){
for (int integer=1; integer <=LoopCount; integer++){```

10. You only need one for loop and it needs to look more like this:

Code:
`  for (LoopCount = 1; LoopCount <= integer; LoopCount++)`

11. ## WHATS WRONG NOW??

why do i get this compiling error with the following code??

numbers.c: In function `main':
numbers.c:33: `for' loop initial declaration used outside C99 mode

Code:
```int main()  {
int oneNumber =0;            // hold the valid integer entered
int countPositiveFactors =0; // accumulate a sum , so should be initialize to 0
int sumPositiveFactors =0;    // accumulate a sum , so should be initialize to 0
int prodPositiveFactors = 1; // accumulate a product so should be initialize to 1

while (1)
{
printf("Enter an integer > 1 :");
scanf("%d", &oneNumber);
if (oneNumber > 1)
break;
else
printf("Error: Number should be > 1\n");
_flushall(); // to flush all streams e.g. stdin

}

printf("\n\nHere is a list of the positive factors of %d\n",oneNumber);
for (int i=1;i<=oneNumber;i++)
{
if (oneNumber%i==0) // one factor found
{
countPositiveFactors++; // add 1 to count of positive factors
printf("%d ",i);        // print this factor
sumPositiveFactors+=i;  // add this factor e.g. i to the sum
prodPositiveFactors*=i; //  multiply this factor with the previous factors

}
}

printf ("\n\nThe number of positive factors of %d is %d.\n",oneNumber, countPositiveFactors);
printf ("The sum of the positive factors of %d is %d.\n",oneNumber, sumPositiveFactors);
printf ("The product of the positive factors of %d is %d.\n",oneNumber, prodPositiveFactors);

return 0;
}```

12. >>for (int i=1;i<=oneNumber;i++)
You can't declare variables within the loop like that, at least not in c89.

To fix your problem, move the declaration of i to the top of the code block.

Code:
```int main()
{
int i;
...
/* Lots more stuff here */

for (i=1;i<=oneNumber;i++)```

13. Closed. Re-posted over here