Example Program
Here is a simple Python program which computes p(n), the number of partitions, using the recurrence resulting from the pentagonal number theorem.
pentagonal = lambda n : n*(3*n-1)/2 def generalised_pentagonal(n): # 0, 1, -1, 2, -2 if n < 0: return 0 if n%2 == 0: return pentagonal(n/2+1) else: return pentagonal(-(n/2+1)) pt = for n in range (1, 1000+1): r = 0 f = -1 i = 0 while 1: k = generalised_pentagonal(i) if k > n: break if i%2==0: f = -f r += f*pt i += 1 pt.append(r) print ptRead more about this topic: Pentagonal Number Theorem
Famous quotes containing the word program:
“The square dance fiddlers first concern is to carry a tune, but he must carry it loud enough to be heard over the noise of stamping feet, the cries of the caller, and the shouts of the dancers. When he fiddles, he fiddles all over; feet, hands, knees, head, and eyes are all busy.”
—State of Oklahoma, U.S. public relief program (1935-1943)
“Religious fervor makes the devil a very real personage, and anything awe-inspiring or not easily understood is usually connected with him. Perhaps this explains why, not only in the Ozarks but all over the State, his name crops up so frequently.”
—Administration in the State of Miss, U.S. public relief program (1935-1943)