more useful options PerlMonks

### Comment on

 Need Help??

Sorry but I couldn't resist.
```#!/usr/bin/perl

\$|=1;\$N=shift||100;\$M=int(3.3*\$N)
;\$t[0]=2;\$s[0]=2;sub z{\$a=\$r=00};
for(                         \$k=1
;\$k<\$M   ;\$k++){\$a=\$r=0;   };for(
\$k=01;   \$k<\$M;\$k++){&z;   for(\$i
=\$N;\$i   >=0;\$i--){\$a=\$t   [\$i]*(
\$k)+\$r   ;\$t[\$i]=int(\$a%   10);\${
r}=int   (\$a/10);}\$K=(\$k   <<1)+1
;&{z};   map{\$a=\$t[\$_]+(   10)*((
\$r));;   \${t}[\$_]=int(\$a   /(\$K))
;\${r}=   int((\$a)%(\$K))}   (0..\$N
);if((   \$r>=(int((\$K)/2   )))){;
;;\${t}   [\$N]++}while(\$t   [\$N]>9
){\${t}   [\$N]-=10;;\$t[\$N   -1]++}
&z();   for(\$i=\$N;\$i>=0   ;\$i--){
\$a=    (\$t[\$i]+\$s[\$i]+   \$r);\${s}
[\$i]=int(\$a%10);\$r=int(\$a/10)}if(
\$k>\$x+3){\${x}=\$k;;print"\$s[\$y++]"
;};}for(\$y..\${N}){print"\$s[\$_]";}
You can pass the desired number of digits as parameter on the commandline.

Of course the method used was choosed more for its simplicity than for its speed.
(But this code could be optimized several ways, by adding 'use integer;' for example...)

For REAL program you should use Math::GMP or Math::Float and real formulae

Any search on the net would give you a lot of start point, you might try this one.

"Trying to be a SMART lamer" (thanx to Merlyn ;-)

In reply to Simple Pi calculator by arhuman
in thread Calculating Pi by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [ozboomer]: There's a text file with lots of sections in it, like an '.ini/.conf' file. Each section can be 'used' or 'unused' by its application (more...) [ozboomer]: Some folk want to use the text file as 'storage', keeping ALL items in it (a database); others call it an 'active document' that should only contain 'in-use' sections. Is there a 'good practice' for this sort of thing?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-05-21 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (151 votes). Check out past polls.

Notices?