summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/c-pascal/prog/fib.py
blob: 3c0bc3d8a23ddbc7e94a782802578fde0a6443ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Just a little test program
from sys import stderr

class FibSeries:
    """Returns all the elements of Fibonacci series up to a given number.
    
       Requires one parameter (the number we're going up to)."""
       

    def __init__(self,number):
        self.series=[1,1]	
        a,b=1,1
	
        while b<number:
            a,b=b,a+b
            if b<number: self.series.append(b)

    def writeout(self):
        cnt=0
        while cnt<len(self.series):
            stderr.write(str(self.series[cnt])+" ")
            cnt+=1
        stderr.write("\n")
	
meine = FibSeries(115)
meine.writeout()