Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Question

Posted on 2004-10-28
9
Medium Priority
?
219 Views
Last Modified: 2010-04-15
How do I write a script that determines if a number is a Perfect Number or if it is a Prime Number?
0
Comment
Question by:testn1
9 Comments
 
LVL 2

Accepted Solution

by:
Sadrul earned 1000 total points
ID: 12440847
find all the proper divisors of the number. if there is only one (1), then the number is prime. otherwise, add the divisors. if the summation equals the number itself, it's a perfect number.

you can look up on the Sieve of Eratosthenes for effective way of finding a lot of prime numbers.

-- Adil
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12441290
testn1,

This sounds like a homework assignment .. Let us see the work that you have done so far.

sunnycoder
0
 
LVL 6

Expert Comment

by:stsanz
ID: 12442493
How do I title a question asking how to write a script that determines if a number is a Perfect Number or if it is a Prime Number?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:stefan73
ID: 12443511
Hi stsanz,
Title it "Moo"? :-)
0
 
LVL 2

Expert Comment

by:shah1d1698
ID: 12456073
Here is some code to do your job...
Use the following two functions in your program and see whether it works or not.

<code edited by sunnycoder, Page Editor>
0
 
LVL 2

Expert Comment

by:shah1d1698
ID: 12461330
Did my functions work???
0
 
LVL 2

Expert Comment

by:shah1d1698
ID: 12461643
Sorry..I messed up..
0
 
LVL 2

Assisted Solution

by:shah1d1698
shah1d1698 earned 1000 total points
ID: 12461644
>>To testn1....

u'll find useful info about determining perfect number at the following site..

http://home1.pacific.net.sg/~novelway/MEW2/lesson1.html 
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question