derpp has asked for the wisdom of the Perl Monks concerning the following question:
I've decided to give up on my stock thing until later, when I don't have a massive headache from trying over and over again. So, I've moved on to a much simpler one to try. I've managed to mess that one up too. So, I'm trying to make the first number go up by 10%, second number go down by 5%, third up by 10%, fourth down by 5%, and so on. If you're wondering about the 1100 and 950, I've already multiplied 1.1% and 0.95% by 1000 to save lines. So yeah, my problem is that when I run it, nothing comes out. It's just blank. I've tried rewriting it, but to no avail. Maybe I'm just doing this totally wrong.
use warnings; use strict; my @array; print "Enter the number of years: "; my $i = <STDIN>; my @p = 100; sub number { for(1..100) { if ($_ % 2) { my $y = number($p[-1]*1100); push @array, $y; } else { my $z = number($p[-1]*950); push @array, $z; } } } print $array[$i-1];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: recursive. again.
by Anonymous Monk on Aug 24, 2010 at 00:03 UTC | |
|
Re: recursive. again.
by toolic (Bishop) on Aug 24, 2010 at 00:03 UTC | |
by derpp (Acolyte) on Aug 24, 2010 at 00:13 UTC | |
by toolic (Bishop) on Aug 24, 2010 at 00:27 UTC | |
by derpp (Acolyte) on Aug 24, 2010 at 00:36 UTC | |
by muba (Priest) on Aug 24, 2010 at 01:59 UTC | |
by TomDLux (Vicar) on Aug 24, 2010 at 05:45 UTC |