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

x
Solved

# Question

Posted on 2004-10-28
Medium Priority
219 Views
How do I write a script that determines if a number is a Perfect Number or if it is a Prime Number?
0
Question by:testn1

LVL 2

Accepted Solution

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.

0

LVL 45

Expert Comment

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

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

LVL 12

Expert Comment

ID: 12443511
Hi stsanz,
Title it "Moo"? :-)
0

LVL 2

Expert Comment

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

ID: 12461330
Did my functions work???
0

LVL 2

Expert Comment

ID: 12461643
Sorry..I messed up..
0

LVL 2

Assisted Solution

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

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.
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
###### Suggested Courses
Course of the Month11 days, 13 hours left to enroll