<DIV>
<DIV>dear friends ,</DIV>
<DIV>I found a code which calculates pi with an interesting algorithm the programme code is below:</DIV>
<DIV>from sys import stdout</DIV>
<DIV>def f((q,r,t,k)):<BR> n = (3*q+r) / t<BR> if (4*q+r) / t == n:<BR> return (10*q,10*(r-n*t),t,k,n)<BR> else:<BR> return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1)</DIV>
<DIV># Call pi(20) for first 20 digits, or pi() for all digits<BR>def pi(n=-1):<BR> printed_decimal = False<BR> r = f((1,0,1,1))<BR> while n != 0:<BR> if len(r) == 5:<BR> stdout.write(str(r[4]))<BR> if not printed_decimal:<BR> stdout.write('.')<BR> printed_decimal = True<BR> n -= 1<BR> r = f(r[:4])<BR> #stdout.write('\n')</DIV>
<DIV>if __name__ == '__main__':<BR> from sys import argv<BR> try:<BR> digit_count = long(argv[1])<BR> except:<BR> digit_count=int(raw_input('How many digits? :'))<BR> pi(digit_count)<BR> </DIV>
<DIV>This code gives the number in an unusual format like "3.1415'None'" it has a number part and a string part . I want to seperate these from easc other but I couldn't manage. I mean when I try to turn it into string format then try to use things like [:4] or like that they don't work.Any idea how to seperate this 'None' from the number and make it a real normal number on which I can do operations like +1 -1 or like that :)</DIV>
<DIV>Regards</DIV></DIV><p>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam? Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com