Table of Contents

Corning Community College

CSCS2330 Discrete Structures

~~TOC~~

Project: EXPLORING WEIRD NUMBERS (ewn1)

Objective

To continue to apply your skills in implementing an algorithm that determines certain attributes of a number based on its factor composition.

Background: Weird and Semi-perfect numbers

In the previous project, we explored the computation of abundant, perfect, and deficient numbers. There is one more in that “genre”, and that is the classification of weird numbers, with a related semi-perfect classification.

A semi-perfect number is a natural number that is equal to the sum of all or some of its factors. A semi-perfect number that is equal to the sum of all its proper divisors is a perfect number. So by this definition, semi-perfect numbers can be abundant or perfect numbers, but that is limited by the constraining requirement of some combination of sums equalling the number we are evaluating.

Some examples of semi-perfect numbers include:

A weird number is defined as a natural number that is abundant but not semi-perfect. In other words, the sum of the factors (divisors including 1 but not itself) of the number is greater than the number, but no subset of those divisors sums to the number itself.

Some examples of weird numbers include:

Subset of sums

Calculating semi-perfect and weird numbers requires us to analyze the various combinations of factor sums. This requires some additional consideration in our implementation, as we need to try every possible combination to see if there is a match.

Program: Description and Specifications

You are to write a program (ewn1.c) that:

Basically, requirements are the SAME as for ewn0, only we are adding in the check, processing, and output identification of semi-perfect and weird numbers.

There exists the possibility that there may be multiple combinations of factor subset sums that will prove semi-perfection. For the purposes of this project, display the FIRST match you find (as such, you do not need to find EVERY possible combination, merely the first and then bail out of your attempt).

Grabit Integration

For those familiar with the grabit tool on lab46, I have made some skeleton files and a custom Makefile available for this project.

To “grab” it:

lab46:~/src/discrete$ grabit discrete ewn1
make: Entering directory '/var/public/SEMESTER/CLASS/ewn1'

‘/var/public/SEMESTER/CLASS/ewn1/Makefile’ -> ‘/home/USERNAME/src/CLASS/ewn1/Makefile’
‘/var/public/SEMESTER/CLASS/ewn1/ewn1.c’ -> ‘/home/USERNAME/src/CLASS/ewn1/ewn.c’

make: Leaving directory '/var/public/SEMESTER/CLASS/ewn1'
lab46:~/src/discrete$ cd ewn1
lab46:~/src/discrete/ewn1$ ls
Makefile          ewn1.c
lab46:~/src/discrete/ewn1$ 

Just another “nice thing” we deserve.

NOTE: You do NOT want to do this on a populated ewn0 project directory– it will overwrite files. Only do this on an empty directory.

Makefile fun

With the Makefile, we have your basic compile and clean-up operations:

Execution

Your program output should be as follows (given the specific inputs via the command-line):

lab46:~/src/discrete/ewn1$ ./ewn1 66 70
[66] abundant:  1+2+3+6+11+22+33 = 78 (semi-perfect: 11+22+33)
[67] deficient: 1 = 1
[68] deficient: 1+2+4+17+34 = 58
[69] deficient: 1+3+23 = 27
[70] abundant:  1+2+5+7+10+14+35 = 74 (weird: none)
lab46:~/src/discrete/ewn1$ 

As with ewn0, starting and ending at any acceptable value is possible, as well as the starting value being higher than the ending value.

Submission

Project Submission

To submit this program to me using the submit tool, run the following command at your lab46 prompt:

lab46:~/src/discrete/ewn1$ make submit
removed 'ewn1'

Project backup process commencing

Taking snapshot of current project (ewn1)      ... OK
Compressing snapshot of ewn1 project archive   ... OK
Setting secure permissions on ewn1 archive     ... OK

Project backup process complete

Submitting discrete project "ewn1":
    -> ../ewn1-DATESTRING-HOUR.tar.gz(OK) 

SUCCESSFULLY SUBMITTED

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

Submission Criteria

To be successful in this project, the following criteria must be met: