User Tools

Site Tools


Sidebar

projects

ntr0 (due 20210825)
pct1 (bonus; due 20210819)
wcp1 (due 20210818)
uom0 (due 20210901)
pct2 (due 20210825)
wcp2 (due 20210825)
pnf0 (due 20210901)
pct3 (bonus; due 20210901)
wcp3 (due 20210901)
pnf1 (due 20210908)
pct4 (due 20210908)
wcp4 (due 20210908)
pnf2 (due 20210915)
gfo0 (due 20210915)
pct5 (bonus; due 20210915)
wcp5 (due 20210915)
pnf3 (due 20210922)
pct6 (due 20210922)
wcp6 (due 20210922)
saf0 (due 20210929)
pct7 (bonus; due 20210929)
wcp7 (due 20210929)
saf1 (due 20211006)
pct8 (due 20211006)
wcp8 (due 20211006)
saf2 (due 20211020)
pct9 (bonus; due 20211020)
bwp1 (bonus; due 20211020)
wcp9 (due 20211020)
fom0 (due 20211027)
gfo1 (due 20211027)
pctA (due 20211027)
wcpA (due 20211027)
pctB (bonus; due 20211103)
wcpB (due 20211103)
mpg0 (due 20211110)
pctC (due 20211110)
wcpC (due 20211110)
gfo2 (due 20211117)
pctD (bonus; due 20211117)
pctE (bonus; due 20211201)
bwp2 (bonus; due 20211201)
EoCE (due 20211209)
haas:fall2021:discrete:projects:ewn0

Corning Community College

CSCS2330 Discrete Structures

Project: EXPLORING WEIRD NUMBERS (ewn0)

Objective

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

Background: Numerology

In ancient times, numbers and properties of numbers carried certain mystical qualities. In the Pythagorean tradition (at least as history attributes it), we have the following classifications:

  • abundant number: a number wherein the sum of its factors is greater than itself
    • for example, in the number 12, we have:
      • the factors: 1, 2, 3, 4, 6
      • the sum thereof: 1 + 2 + 3 + 4 + 6 = 16
      • as 16 is greater than 12, 12 is considered an abundant number
  • perfect number: a number wherein the sum of its factors is equal to itself
    • for example, in the number 6, we have:
      • the factors: 1, 2, 3
      • the sum thereof: 1 + 2 + 3 = 6
      • as 6 is equal to 6, 6 is considered a perfect number
  • deficient number: a number wherein the sum of its factors is less than itself
    • for example, in the number 21, we have:
      • the factors: 1, 3, 7
      • the sum thereof: 1 + 3 + 7 = 11
      • as 11 is less than 21, 21 is considered a deficient number

There are two activities at play here:

  1. the knowledge of the factors of a number (which we've had some experience with in our prime number endeavors)
  2. the sum of those factors to make the above determination of attribute

We will be writing a program that will perform these actions for a range of numbers.

Program: Description and Specifications

You are to write a program that:

  • accepts two values via command-line arguments
    • argv[1]: the starting value
    • argv[2]: the ending value
    • proper error checking should be performed so that the program cannot proceed (and should display an appropriate error) if the following conditions are encountered:
      • values less than 2 are provided, with an error “invalid range specification”
      • missing argv[2], with the error “missing upper bound”
      • missing both argv[1] and argv[2]: “insufficient data provided”
    • assumptions: as inferred in the error checking above, processing can start at 2, and proceed up to the maximum value of the data type.
      • while we are including 1 as a factor, we are not including the number itself in the list of factors.
    • perform the necessary calculations to determine the factors, from (and including) argv[1] through (and including) argv[2]
      • be sure to STORE the factors
      • sum the factors, and determine its abundant/perfect/deficient quality
      • NOTE: the starting value does NOT have to be less than the ending value. We are merely connecting the two.
    • display the results for that number, in the following format:
      • [NUMBER] quality: F1+F2+...+FN = SUM
      • for example: [8] deficient: 1+2+4 = 7

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 ewn0
make: Entering directory '/var/public/SEMESTER/CLASS/ewn0'

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

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

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:

  • make: compile everything
  • make debug: compile everything with debug support
  • make clean: remove all binaries
  • make save: make a backup of your project
  • make submit: submit project (uses submit tool)

Execution

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

lab46:~/src/discrete/ewn0$ ./ewn0 2 16
[2] deficient: 1 = 1
[3] deficient: 1 = 1
[4] deficient: 1+2 = 3
[5] deficient: 1 = 1
[6] perfect:   1+2+3 = 6
[7] deficient: 1 = 1
[8] deficient: 1+2+4 = 7
[9] deficient: 1+3 = 4
[10] deficient: 1+2+5 = 8
[11] deficient: 1 = 1
[12] abundant:  1+2+3+4+6 = 16
[13] deficient: 1 = 1
[14] deficient: 1+2+7 = 10
[15] deficient: 1+3+5 = 9
[16] deficient: 1+2+4+8 = 15
lab46:~/src/discrete/ewn0$ 

And we don't have to start at 2:

lab46:~/src/discrete/ewn0$ ./ewn0 37 42
[37] deficient: 1 = 1
[38] deficient: 1+2+19 = 22
[39] deficient: 1+3+13 = 17
[40] abundant:  1+2+4+5+8+10+20 = 50
[41] deficient: 1 = 1
[42] abundant:  1+2+3+6+7+14+21 = 54
lab46:~/src/discrete/ewn0$ 

Additionally, we can also do this:

lab46:~/src/discrete/ewn0$ ./ewn0 30 17
[30] abundant:  1+2+3+5+6+10+15 = 42
[29] deficient: 1 = 1
[28] perfect:   1+2+4+7+14 = 28
[27] deficient: 1+3+9 = 13
[26] deficient: 1+2+13 = 16
[25] deficient: 1+5 = 6
[24] abundant:  1+2+3+4+6+8+12 = 36
[23] deficient: 1 = 1
[22] deficient: 1+2+11 = 14
[21] deficient: 1+3+7 = 11
[20] abundant:  1+2+4+5+10 = 22
[19] deficient: 1 = 1
[18] abundant:  1+2+3+6+9 = 21
[17] deficient: 1 = 1
lab46:~/src/discrete/ewn0$ 

Submission

Project Submission

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

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

Project backup process commencing

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

Project backup process complete

Submitting discrete project "ewn0":
    -> ../ewn0-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.

haas/fall2021/discrete/projects/ewn0.txt · Last modified: 2019/10/21 11:38 by 127.0.0.1