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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |