Re: on the way to find pi!
when we change the code that way the programme gets awful slow when I want to calculate say 100 digits or more .Can't we just get the numbers out of there without changing the code radically thus not making the programme sloww? Do you Yahoo!? Yahoo! Search presents - Jib Jab's 'Second Term'-- http://mail.python.org/mailman/listinfo/python-list
Re: on the way to find pi!
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import math math.pi 3.1415926535897931 Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: on the way to find pi!
that's just little near to pi... pi is so far away ;)__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: on the way to find pi!
write the code type str(pi(5)) and see what I mean__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: on the way to find pi!
Ali Polatel wrote: write the code type str(pi(5)) and see what I mean it helps if you post the code you want help with in your first post, so people don't have to guess. the pi function doesn't return anything, it prints the value to stdout (that's what the stdout.write things are doing). if a function doesn't return anything, Python automagically inserts a return None, which explains the None you're seeing (well, it prints 3.1415None after your modification, so you probably did something else to get 3.1415'None'). if you want the digits, you have to change the stdout.write calls to something else. say: def pi(n=-1): output = printed_decimal = False r = f((1,0,1,1)) while n != 0: if len(r) == 5: output += str(r[4]) if not printed_decimal: output += '.' printed_decimal = True n -= 1 r = f(r[:4]) return output (this returns a string. to convert it to a Python float, use float(pi(x)). if x is large enough, that gives you the same thing as math.pi). /F -- http://mail.python.org/mailman/listinfo/python-list