Make a program to calculate pi to the n'th decimal. Input the variable at runtime. Program In the language of you choice. (and none of the print"3.1415" crap.)
Name:
Anonymous2007-09-14 10:48 ID:WWWs1FtP
It works on that link (Firefox and IE tested), put a number (and nothing else) in the input field. I don't exactly put error handling in brainfuck.
That implementation is very strict and if it works there, it should work everywhere. No moving to before memory cell 0, no overflowing or underflowing. EOF = 0. Moving past 30000 is allowed to be Turing complete, but this program doesn't go there by far.
Only issue with my code is that the highest number you can input is 254 before the counter overflows. I guess it gets weird input on your implementation.
And yes, it's supposed to output 3.142857 repeating. That's 22 / 7, it's pretty hard to really calculate pi in brainfuck.
>>41 It works on that link (Firefox and IE tested), put a number (and nothing else) in the input field.
Ah, now it works
Very nice work.
Name:
Anonymous2007-09-14 13:09 ID:p0bpMm5E
It's really too bad that in the real world, you never have to do stuff like calculate Pi or factorials, because that's pretty much the only thing useless toy languages really shine at.
>>27 >>44
This ``challenge'' is officially crap. Methods of pi digit extraction are no secret, and most are trivial to implement. This tests your ability to use Google and nothing else.
>>50
It would also be any one of these
1
10
100
10000
1000000000000000000000
Name:
Anonymous2007-09-14 22:13 ID:MPVsRCXO
<?php
get_pi();
?>
winrar
Name:
Anonymous2007-09-14 22:14 ID:pmk4hbO8
Protip: Use Manchin's formula:
pi = 4*(4*arctan(1/5) - arctan(1/239))
If you want it more precise:
pi = 4*(183*atan(1/239)+32*atan(1/1023)-68*atan(1/5382)+12*atan(1/113021)-100*atan(1/6826318)-12*atan(1/33366019650)+12*atan(1/43599522992503626068))
Use modulus division to get the digit you want. Trivial.
But, let's get serious... pi to 30 digits is enough to compute the visible universe with almost no error. For most cases, you don't need lots of digits. It's a parlor trick.
Next?
Name:
Anonymous2007-09-14 22:16 ID:pmk4hbO8
>>53
It'd be better if I didn't flip digits around, and I spelled Jon Machin's name right.
A student was complaining about digital numbers. 'When I take the root of two and then square it again, the result is already inaccurate!'. Overhearing him, Fu-Tzu laughed. 'Here is a sheet of paper. Write down the precise value of the square root of two for me.'