I was making a division function which takes 3 arguments: nominator, denominator and precession. The code is straight forward, but what amazed me was the thought of finding out the value of Pi. Wow, I can run this code for couple of hours by giving precession as infinite value and may get couple of million digits of Pi after decimal. Let’s run the code, and here is the output:

vishal@ubuntu:~/progs/c$ ./a.out 22 7 100
Ans :3.1428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428

:D, WTF. I am getting repetitive pattern. I didn’t know what has happened. Talked to couple of friends and confirmed the manual division algorithm. All are getting same value. Even the calculator in Gnome (gcalctool) is giving me the same answer. This was strange. But the calculator in windows gives the actual Pi value.  By doing little more googling, I found this:


I WAS SO WRONG. Till date, I was believing that 22/7 is Pi, and it is not. There’s another fractal 355/113 which is more closer to Pi than 22/7 (upto 4-5 digits :)). Here it is:

vishal@ubuntu:~/progs/c$ ./a.out 355 113 1000
Ans :3.1415929203539823008849557522123893805309734513274336283185840707964601769911504424778761061946902654867256637168141592920353982300884955752212389380530973451327433628318584070796460176991150442477876106194690265486725663716814159292035398230088495575221238938053097345132743362831858407079646017699115044247787610619469026548672566371681415929203539823008849557522123893805309734513274336283185840707964601769911504424778761061946902654867256637168141592920353982300884955752212389380530973451327433628318584070796460176991150442477876106194690265486725663716814159292035398230088495575221238938053097345132743362831858407079646017699115044247787610619469026548672566371681415929203539823008849557522123893805309734513274336283185840707964601769911504424778761061946902654867256637168141592920353982300884955752212389380530973451327433628318584070796460176991150442477876106194690265486725663716814159292035398230088495575221238938053097345132743362831858407079646017699115044247787610619469026548672

Following page gives a nice idea about how Pi is approximated and what are different algorithm that modern computers are using. There are plenty of them, and one of them is invented by and Indian scientist in 1910, great, and which is the fastest I guess.


Anyway, I was wondering about the random numbers a few days ago. A friend of mine is using the /dev/random and /dev/urandom to read the random numbers. I was also using this file to read random number some time back. His application needed random numbers for encryption purpose. Suddenly the Pi thing struck into my mind that why people are not using digits of Pi as a random number. I did little bit google on this topic, and here is what I found :)


What a wonderful time spent in last couple of hour!! Life’s good.


4 thoughts on “Pi

  1. i missed it.. :(
    hey man….
    i missed that charming dance on the dance floor of our very own workshop…
    as me and one more guy (probably kanjiyo or vadil)had gone to mehsana to bring
    1/2 inch square aluminium strips…
    12 feet length..
    15 nos.. :)
    i now realize…v could have made a pair of skyscrappers with that much of it…
    wat the hell v did with those strips??? :|

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s