

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Lecture Notes CPSC 121 (Fall 2012)
Today ...
Reading
S. Bowers 1 of 2
Lecture Notes CPSC 121 (Fall 2012)
Q: What does this function compute?
def f(n): r = 1 for i in range(1, n+1): r = r * i return r
Q: How can we write this using a while loop?
def f(n): r = 1 i = 1 while i <= n: r = r * i i = i + 1 return r
S. Bowers 2 of 2