CSci 150: Foundations of computer science I
Home Syllabus Assignments Tests

printable version

Exam 1 Review

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Problem X1r.1.

Tabulate the values taken on by each variable as the program fragment below executes.

int n;
int k;
int i;
n = 32;
k = n + 1;
i = 2;
while(i * i <= n) {
    if(n % i == 0) {
        k = k + i + (n / i);
    }
    i = i + 1;
}