1) What version of perl are you using?

2) As far as I can tell, this isn't really done much in perl:

my $value = 0; my $range = 0; my $phiApprox = 0; my $i = 0; my $temp = 0; my $fibValue1 = 0; my $fibValue2 = 0;

Declare your variables at (or near) first use, for example:

chomp(my $value = <>); chomp(my $temp = <>); my $range = $value + $temp; my $total; for (0 .. $range) { my $fibValue1 = fib($i); my $fibValue2 = fib($i - 1); ... ... $total++; }

Redeclaring variables inside loops is done with alacrity in perl.

3) Note that you can do this in perl:

use strict; use warnings; use 5.010; my $total; $total++; say $total; --output:-- 1

...which would not work in those other languages you know. Yet, paradoxically you will get a warning if you do this:

use strict; use warnings; use 5.010; my $total; my $result = $total + 1; say $result; --output:-- Use of uninitialized value $total in addition (+) at 1perl.pl line 9. 1

In reply to Re: how to speed up program dealing with large numbers? by 7stud
in thread how to speed up program dealing with large numbers? by Solarplight

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.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.