Computing.Net > Forums > Unix > unix shell programs

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

unix shell programs

Reply to Message Icon

Name: sarvesh kumar sinha
Date: April 27, 2003 at 01:37:17 Pacific
OS: win mill.
CPU/Ram: 128mb
Comment:

can any gentle man e mail me solution of the following problem?
problem:write shell program to check whether the given number is a perfect number or not



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: April 27, 2003 at 07:06:32 Pacific
Reply:

You have two options. The first being to compare to a relatively short list fixed list of numbers that are know to be perfect. The second checks against he published math formula and is very processor intesive.

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

if [ $num -lt 500 ] ; then
if [ $num -eq 6 -o $num 28 -o $num 496 ] ; then
echo "Perfect number found"
else
echo "Not a perfect number"
fi
else
echo "Sorry $num out of range"
fi


0

Response Number 2
Name: David Perry
Date: April 28, 2003 at 05:46:52 Pacific
Reply:

http://primes.utm.edu/glossary/page.php?sort=PerfectNumber

Theorem:
If 2k-1 is prime, then 2k-1 (2k-1) is perfect and every even perfect number has this form.
It turns out that for 2k-1 to be prime, k must also be prime--so the search for Perfect numbers is the same as the search for Mersenne primes. Armed with this information it does not take too long, even by hand, to find the next two perfect numbers: 33550336 and 8589869056. See the first page on Mersennes below for a list of all know perfect numbers.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: unix shell programs

Unix Shell Program www.computing.net/answers/unix/unix-shell-program/4881.html

Unix Shell program www.computing.net/answers/unix/unix-shell-program/3441.html

Shell Programming www.computing.net/answers/unix/shell-programming/1017.html