If you ask Python to generate the 1000th term using a recursive algorithm, it can't handle it, complaining that you've exceeded the allowed depth of recursion (you can "call yourself" at most 999 deep). The function x(n) invokes itself (like factorial or fibonacci). def x(n): if n==1 : return 0 return 3*(x(n-1)+2*n-3) # x.py - lrb - 3/5/2012 if __name__ == "__main__": import sys print "Enter an integer:" number = sys.stdin.readline() print "" + str(x(int(number))) Here's what x.py tells you when you ask it what the 999th term is. lee@lee-Inspiron-530:/media/HP USB FD$ python x.py Enter an integer: 999 440690273160268878963485086584048121988474010917382722554973456075609 532448901633180259437950202687321303259232290860785316984860700206303 955114241752651224675873408399440267959338258076321613758130133372529 539347042982605207698146020522057684695558163502059375160114801849018 132346298605821789418305378740276756187926194096742805466102629298972 852134694966312536457747390615453312898505588339646862703020142029890 479621367604783461882915721944003538122044057700922967618403670 C++ and Python output differ at n=34 1: 0 2: 3 3: 18 4: 69 5: 228 6: 711 7: 2166 8: 6537 9: 19656 10: 59019 11: 177114 12: 531405 13: 1594284 14: 4782927 15: 14348862 16: 43046673 17: 129140112 18: 387420435 19: 1162261410 20: 3486784341 21: 10460353140 22: 31381059543 23: 94143178758 24: 282429536409 25: 847288609368 26: 2541865828251 27: 7625597484906 28: 22876792454877 29: 68630377364796 30: 205891132094559 31: 617673396283854 32: 1853020188851745 33: 5559060566555424 34: 16677181699666466 >>> print 3**30-3*30 205891132094559 >>> print 3**31-3*31 617673396283854 >>> print 3**32-3*32 1853020188851745 >>> print 3**33-3*33 5559060566555424 >>> print 3**34-3*34 16677181699666467 >>> Here's a tiny-c program that uses int arrays to do multi-precision arithmetic. multseq.tc |