![]() |
|
#1
|
|||
|
|||
getting pWned by this codeI have two assignments for my computer science class that am too dumb to figure out and am hoping one of you code h4x0rz can help me out.
1. Two numbers are called amicable if the proper divisors of one sums to the other. For example, the pair 220 and 284 are amicable numbers: The proper divisors of 220 are: 1+2+4+5+10+11+20+22+44+55+110 = 284 The proper divisors of 284 are: 1+2+4+71+142 = 220 Write a program which accepts two integers and determines whether or not the integers form an amicable pair. Allow the user to repeat the calculation as many times as he/she wishes. (see sample run). Enter two numbers: 220 284 220 and 284 are amicable Run again? Y or y for Yes: y Enter two numbers: 1000 1024 1000 and 1024 are not amicable Run again? Y or y for Yes: n Bye. this is my code so far: CPP / C++ / C Code:
2. Write a program to test for insipid integers between 1 and 99. Your program will prompt the user for a number from 1 to 99. It will then print out the sequence as described above and tell whether the number is insipid or not. For example, if you begin with 25 the sequence is 25 29 (since 29 = 22 + 52) 85 (since 85 = 22 + 92) 89 (89 = 82 + 52) etc. Notes: a) if any term in the sequence equals 1, then all successive terms are 1 b)if any term in the sequence equals 58, then the sequence cycles: …, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145….. It is known that either condition a or b MUST occur. An integer N0 is called insipid if condition (a) occurs. Sample Run : number : 2 The sequence starting at 2 is : 2 4 16 37 58 Not insipid Run again (Y for yes) Y number : 13 The sequence starting at 13 is : 13 10 1 insipid Run again (Y for yes) N Note: You will need to separate the digits of a number of at most three digits. Use / and %. The largest number you will have is a three digit number. CPP / C++ / C Code:
Last edited by LuciWiz : 21-Oct-2004 at 01:34.
Reason: Please insert your C code between [c] [/c] tags
|
|
#2
|
||||
|
||||
|
For the first program, try outputting all the 'proper' values as you arrive at them to see if you are calculating them properly.
For the second, I didn't read it close enough... I'll get back to it later if noone else responds, __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Formatting C / C++ code | WaltP | C Programming Language | 1 | 07-Jan-2008 00:59 |
| very difficult code - program | gaurav_sting | C++ Forum | 1 | 16-Jun-2004 01:59 |
| Explain code in MS STL's binary_search | rom | C++ Forum | 11 | 07-Mar-2004 21:11 |
| something wrong with this code | loon | MySQL / PHP Forum | 5 | 07-Jul-2003 06:55 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The