# a01 - Assignment 1: Algorithms CSci 1001, Spring 2010 22...

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

Assignment 1: Algorithms CSci 1001, Spring 2010 22 January 2009 Due date: Due in hardcopy at the beginning of class on Wednesday, Febru- ary 3, 2009. See the “assignment rules” ±le on the class “Assignments” web page for assignment rules. 1 Reading Algorithms Consider the following algorithm. Input : A positive integer. Output : A list of integers. Procedure : Presented as pseudocode: 1 Get the input number n 2 Set i to be 1 3 Set sum to be 0 4 While (i < n) 5 If the remainder of n divided by i is 0 then 6 Print i 7 Set sum to be sum + i 8 Set i to be i + 1. 9 Print "sum =", sum 10 Stop Problem 1.1 Draw a fowchart representing this algorithm. Problem 1.2 What does this algorithm print iF the input is 6 ? Problem 1.3 What does this algorithm print with input iF the input is 42 ? 1

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

View Full Document
Problem 1.4 The input requires that the input be a positive integer. How- ever, what would happen if you used as input a negative integer n ? Problem 1.5 Does the algorithm print the value of the input number always, sometimes, or never? (So, for example, if n equals 10, does 10 appear as any of the numbers printed by the algorithm?) If sometimes, then explain under what conditions that value is printed. 2 Writing Algorithms: Decrementing a Count- down Timer Many devices, such as microwave ovens, include a countdown timer. One part of a countdown timer is a function that takes the current amount of
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/28/2010 for the course CSCI 1001 taught by Professor Staff during the Spring '08 term at Minnesota.

### Page1 / 5

a01 - Assignment 1: Algorithms CSci 1001, Spring 2010 22...

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

View Full Document
Ask a homework question - tutors are online