From a8eedd102ba32233d52fbb45b1f67b255d6e8396 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Tue, 28 Aug 2007 21:36:32 +0000 Subject: Examples update. --- (limited to 'data') diff --git a/data/math/fibonacci b/data/math/fibonacci index 7788182..9bc1acb 100644 --- a/data/math/fibonacci +++ b/data/math/fibonacci @@ -2,4 +2,3 @@ a, b = 0, 1 while b < 1001: print b, a, b = b, a+b - diff --git a/data/math/sierpinski b/data/math/sierpinski new file mode 100644 index 0000000..c034d93 --- /dev/null +++ b/data/math/sierpinski @@ -0,0 +1,25 @@ +# Sierpinski triangles +size = 5 +modulus = 2 + +lines = modulus**size + +vector = [1] +for i in range(1,lines+1): + vector.insert(0,0) + vector.append(0) + +for i in range(0,lines): + newvector = vector[:] + for j in range(0,len(vector)-1): + if (newvector[j] == 0): + print " ", + else: + remainder = newvector[j] % modulus + if (remainder == 0): + print "O", + else: + print ".", + newvector[j] = vector[j-1] + vector[j+1] + print + vector = newvector[:] diff --git a/data/python/recursion b/data/python/recursion new file mode 100644 index 0000000..c34638d --- /dev/null +++ b/data/python/recursion @@ -0,0 +1,10 @@ +def countbackwards(number): + print "I have the number", number + if number > 0: + print "Calling countbackwards again!" + countbackwards(number-1) + else: + print "I am done counting" + +number = input("Enter a number: ") +countbackwards(number) -- cgit v0.9.1