a01-key

# a01-key - Assignment 1 Comments and Key CSci 1001 Spring...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2
2 Problem 1: Reading Algorithms Problem 1.1 : See Figure 1 Problem 1.2 : 1 2 3 sum =6 Problem 1.3 : 1 2 3 6 7 14 21 sum =54 Problem 1.4 : If n is negative the loop continuation condition i < n will be false imme- diately, so the loop body is never executed. However, line 9 will still be executed, always printing sum=0 . Problem 1.5 : Since the loop only executes for i < n , line 6 will never print out the value of n . So the only possibility will be line 9. This will print out the value of n if and only if the numbers that divide n evenly also sum to n (as occurs for n = 6, for example). 3 Problem 2: Decrementing a Countdown Timer

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

a01-key - Assignment 1 Comments and Key CSci 1001 Spring...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online