# help with this problem

• 08-26-2007
mumay
help with this problem
Problem 3. Write a complete program that implements the following algorithm that computes the greatest common divisor of two given positive integers. For example, if 441 and 252 are input, then the program should print that 63 is their greatest common divisor:

Algorithm 3.1 The Euclidean Algorithm
To find the greatest common divisor gcd of two positive integers m and n:
1. Subtract m from n repeatedly until n<m.
2. Interchange the values of m and n.
3. Repeats steps 1-2 until m=0
4. Then n is the greatest common divisor of the two original numbers

Problem 4. Write a program that returns the factorial of 150. The output should be 2 3 5 5

Problem 5. Write a program that inputs a positive integer n and then prints a triangle of asterisk n lines high 2n-1 columns wide. For example, if the input is 5 then the output should be.

can give a code for this thanks
• 08-26-2007
MacGyver
Quote:

Originally Posted by mumay
can give a code for this thanks

Yes, I could, but I don't feel like doing homework for a lazy student.

Try it on your own first and find out where you get stuck. Ask specific questions if you must, but make sure it's you doing the work. If you absolutely hate C++, don't take a course on it. ;)
• 08-26-2007
anon
Problem 3:
The internet is full of the implementations of this algorithm. If you can't program following the outlined steps, you could google.

Problem 4:
The program is not supposed to calculate factorial (quite hard for 150 ;)) but factors. Hint: you may need to find out if a value is divisible by 2, 3, 4 etc.

Problem 5:
No hints for printing asterisks.
• 08-26-2007
mumay
Quote:

Originally Posted by MacGyver
Yes, I could, but I don't feel like doing homework for a lazy student.

Try it on your own first and find out where you get stuck. Ask specific questions if you must, but make sure it's you doing the work. If you absolutely hate C++, don't take a course on it. ;)

im trying our teacher did not tech us how to do this im doing it a whole day im reading books but it wont work im having hard time of it i had already try it but always had error so pls help me
• 08-26-2007
Daved
If you've tried it but gotten errors, feel free to post your best attempt along with the errors it gives you and somebody can probably help you with them. Make sure to post the code in [code][/code] tags.