Homework 4
CS17
50 pts., due Mar. 22
For each program, you should turn in the source code and a print-out
showing a sample run (print the output window). Follow the guidelines in
Section 3.7 for the style of your programs. In addition:
- Use descriptive names for variables and named constants. In
addition, write a brief comment for each variable and named constant
describing how it is used.
- Use uppercase characters for named constants with underscores to
separate ``words.'' Use lowercase characters for variables with either
underscores or capitalization to separate ``words.''
- If a formula you use in a statement isn't obvious, comment it. In
general, comment any non-obvious statement or statement block.
Documentation will account for 30% of your grade.
- Write a program which accepts as input a single integer value and
outputs:
- The prime factors of the number, if the number is not prime.
- The statement ``n: prime,'' if the number, n, is prime.
Here is sample input and output:
The number please: 17
17: prime.
The number please: 60
60: 2 2 3 5
Thomas P. Kelliher
Thu Mar 14 13:31:55 EST 1996
Tom Kelliher