ok, i've got a question that i'm having trouble with
Jun 02, 2006 Divide your number by the smallest possible prime factor. Divide your number by the smallest prime factor (besides 1) that divides into it evenly with no remainder. Write the prime factor in the left column and write your answer across from it in the right column. C Program to Find Factors of a Number Using Functions. This program to Find Factors of a Numbering C allows the user to enter any integer value. User entered value will be passed to the Function we created. Within this User defined function, this C program find Factors of a number using For Loop.
Write a program that generates the factors of a number entered by the user. This program has the following requirements:
1. The user must enter a positive integer. If the user enters something else, your program should output an error message and let the user enter a new value. Use a do/while loop to make sure the user input is successful.
2. The factors should be output in increasing order. The lowest factor your program should report is 2. Your program should output 4 factors per line, each factor is in a field of 10 characters.
3. You will need a while loop to report the factors. Here are some helpful hints:
a. If (a % b 0) then a is a factor of b.
b. When you have found a factor, output the factor and then reduce the number you are working with by dividing the number by the factor… ie) b = b / a;
my problem is, i can get the program to factor out, but i dont know how to get it to output in increasing order, or with 4 factors per line, with each factor in field of 10, here is part of my code
i'm not asking for something to copy and paste, just some guidance
- 4 Contributors
- forum 5 Replies
- 581 Views
- 1 Day Discussion Span
- commentLatest Postby skatamaticLatest Post
Syrus_Jones
Ok, i just realized what an idiot i am, i got the factor thing figured out, and putting in increasing order, but........can someone help me with the 4 factors per line, and each factor being in a field of 10...
C++ Program to Find HCF of two numbers
To find the HCF (Highest Common Factor) or GCD (Greatest Common Divisor) of two or more numbers, make prime factors of the numbers and choose the common prime factors. Then the take the highest common factor this highest common factor is HCF of number. For example;