in reply to Re^3: How do I write a program that calculates the sum of all numbers to a number, n?
in thread How do I write a program that calculates the sum of all numbers to a number, n?
Though I’m not positive the answer shouldn’t have been 91 instead
^$n means 0 .. $n - 1; so try:
say [+] ^$n+1;
Not sure about precedence, so it might need brackets. Or maybe:
say [+] ^++$n;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How do I write a program that calculates the sum of all numbers to a number, n?
by Your Mother (Archbishop) on Feb 24, 2015 at 22:03 UTC | |
by raiph (Deacon) on Feb 25, 2015 at 01:23 UTC | |
by Tux (Canon) on Feb 25, 2015 at 11:20 UTC |