![]() |
|
#1
|
|||
|
|||
Program Needed: Perfect Number Program in C languageI need a program in simple C language for generating perfect numbers or checking if the entered number is perfect or not. It is needed urgently.
A perfect number is one whose sum of factors is equal to the number, like 6. 6 has 3 factors 1,2,3 when we add 1+2+3 it is equal to 6; hence 6 is perfect number. Likewise 28 is another perfect number. Can I get this program please? I'm using Borland c++ assembler to compile the programs. |
|
#2
|
|||
|
|||
|
Hello again.
I wrote a c program for above question. I don't know how far it's right and I haven't even checked it for myself because I don't have a compiler. It will be great if anyone of you just check this program, thank you. CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
|
I'd recommend the following:
1) Never use urgent in your posts. People are not likely to treat your post as urgent. They'll answer when they read it and some will even avoid it. 2) Use code tags as described in the sticky 3) Download the free borland compiler and test your program Get it here CPP / C++ / C Code:
CPP / C++ / C Code:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#4
|
|||
|
|||
|
Thanks walt
|
|
#5
|
|||
|
|||
|
GOTCHA
thats the right program but it is having one typo there "b=n%i" its wrong it shd be "b=a%i" well thanks |
|
#6
|
|||
|
|||
Correct Program for finding Perfect NumberHere is the correct program for finding a Perfect Number.
CPP / C++ / C Code:
Last edited by koool_kid : 28-Nov-2004 at 14:41.
Reason: wrongly typed
|
|
#7
|
||||
|
||||
|
Quote:
Next thing to look at it this tutorial since code tags didn't help at all. __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#8
|
|||
|
|||
Re: [Program]Urgently Needed Perfect Number Program in C langhi
how would you go about modifying this so when you put a number in the nearest perfect number can be found? |
|
#9
|
||||
|
||||
Finding the nearest perfect number in a C program using functionsHi Zany,
Did you try running that program? It is wrong!!!! First, lets try to develop the correct way of finding whether a number is perfect or not:
Now, to your question: Quote:
You can create a function say int is_perfect(int number) which returns 1 if the number is a perfect number, and 0 if the number is not perfect. You can use the logic we've developed above. And, in the main function:
Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#10
|
|||
|
|||
Re: [Program]Urgently Needed Perfect Number Program in C lang(the orange, is just trying to get the user within set limits)
Code:
I don't know where to go from here. (I hope I got the scrolly thing to work). I think I need to take each perfect number and - the input number then compare, see which is closest. I was wondering if I could put all the perfect numbers into an array then work with them from that. Thanks for replying so quickly I'm really struggling with this subject. I have limited knowledge I am quite enjoying it at the same time tho |
Recent GIDBlog
Last Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C++ Perfect Number Program Help!!!! | lpwilliams21 | C++ Forum | 4 | 08-Oct-2006 15:01 |
| Converting a number amount to text | Godzilla | C++ Forum | 5 | 31-Mar-2006 11:38 |
| Help with interactive program, please | nika1p2 | C Programming Language | 1 | 09-May-2005 00:22 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 20:25 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The