loops - Pi help with Php (mass looping) -


My primary question is: Is this a lot of loops?

  while ($ decimals <50,000 and $ remainder! = "0") {$ number = floor ($ balance / $ current dividend); // always round down! 10/3 = 3, 10/7 = 1 $ balance = $ balance% $ current dividend; // 10% 3 = 1, 10% 1 $ thisnumber = $ this number $ Number; $ Balance = $ Balance 0; // 10 $ decimal + = 1; }  

Or could I fit more into it? Without crashing / interrupting server

I'm just thinking, besides this is there a more effective method of doing the above work? (Such as 1/3 = 0.3 to 50,000 decimal).

Finally:

I am doing it for PI sources (1 - 1/3 + 1/5 - 1/7 etc.) One,

< P> And I'm thinking that the better one is. (In PHP) I got one that finds pie in 4 seconds in 2000.

But it's not what I want. I want an infinite series that is close to PI

So every fresh user can see it closely ...

But OBV

Thanks a lot ...

Here you have many sources to calculate :

All of them are "practical" in PHP, like any other programming language. A different question is how fast they are or how fast they want to be.

If the formulas become faster or slower, then this is a Math question, not about programming, so I can not help you. I can tell you that as a rule of thumb, there will be low nested loops kept by you, fast algorithms (this is a general rule, do not take it as complete truth!)

By the way Also, since Pi's digits are known to a certain digit, why do not you copy it in a file and then index it? It will be very fast :)

You can see the previous answers to similar questions:


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -