UMBC CS 201, Spring 99
UMBC CMSC 201 Spring '99 CSEE | 201 | 201 S'99 | lectures | news | help

CMSC 201
Programming Project Two

Number Theory

Out: Wednesday 2/24/99
Original Due Date: Midnight, Wednesday 3/10/99

Snow Day Extension: Due: Midnight, Thursday 3/11/99

The Objective

The objective of this assignment is to get you familiar with writing and using functions in C and to heighten your appreciation of mathematics

The Background

The study of mathematics is separated into many fields. The one that leads the student to discover the beauty (yes, beauty) of mathematics is the field of number theory. This field deals with numbers and their relationships to each other and even to nature.

The field of number theory has lead to discoveries such as :

Positive integers can be categorized in many different ways.This project will let you investigate some familiar and some new ways of looking at integers.

The Task

Your mission is to write a program that examines the positive integers between 1 and 30 and categorizes them as follows.

  1. ODD or EVEN
  2. PRIME or COMPOSITE -- a prime number is an integer greater than one that is divisible only by itself and one. Any number that is not "prime" is "composite".
  3. PERFECT/ABUNDANT/DEFICIENT --- as described above
  4. TRIANGULAR -- as described above
Your program will also count the number of integers from 1 to 30 that fall into each category and print a summary at the end.

Your program MUST include the following functions. Do NOT change the functions prototypes given below. You may choose to use more functions if you feel compelled to do so. It is not necessary to use any functions from the C math library. All "predicate" functions below should return 1 for TRUE and 0 for FALSE. You have some flexibility in implementing the other functions. Choose wisely (and use #defines)

Sample Run

retriever[102] a.out This program classifies positive integers between 1 and 30 as Odd/Even, Prime/Composite, Perfect/Abundant/Deficient and Triangular Int Classifications..................................... 1 Odd Deficient Composite Triangular 2 Even Deficient Prime 3 Odd Deficient Prime Triangular 4 Even Deficient Composite 5 Odd Deficient Prime 6 Even Perfect Composite Triangular 7 Odd Deficient Prime 8 Even Deficient Composite 9 Odd Deficient Composite 10 Even Deficient Composite Triangular 11 Odd Deficient Prime 12 Even Abundant Composite 13 Odd Deficient Prime 14 Even Deficient Composite 15 Odd Deficient Composite Triangular 16 Even Deficient Composite 17 Odd Deficient Prime 18 Even Abundant Composite 19 Odd Deficient Prime 20 Even Abundant Composite 21 Odd Deficient Composite Triangular 22 Even Deficient Composite 23 Odd Deficient Prime 24 Even Abundant Composite 25 Odd Deficient Composite 26 Even Deficient Composite 27 Odd Deficient Composite 28 Even Perfect Composite Triangular 29 Odd Deficient Prime 30 Even Abundant Composite Between 1 and 30 there were 15 Odd integers and 15 Even integers 10 Prime numbers and 20 composite numbers 2 Perfect, 5 Abundant and 23 Deficient numbers 7 Triangular numbers retriever[103]

Although your output need not be identical to the above, all information (including the greeting) must be present.

Submitting the Program

You may name your source file for this project as you see fit.
To submit your project, type the following at the Unix prompt:

submit cs201 proj2 xxxxx.c (if you named your file xxxxx.c)

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 proj2

CSEE | 201 | 201 S'99 | lectures | news | help

Sunday, 14-Mar-1999 18:25:27 EST