in reply to Re^5: 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?

say [+] ^$n,$n

(You do not want to change $n, so ++ is out of the question)

Also note that currently $n cannot be a native int when using ++, though that will be fixed.

$ perl6 -e'my Int $n = 10; say ++$n;' 11 $ perl6 -e'my int $n = 10; say ++$n;' Cannot assign to an immutable value in sub prefix:<++> at src/gen/m-CORE.setting:5565 in block <unit> at -e:1 $ perl6 -e'my int $n = 10; say [+] ^$n' 45 $ perl6 -e'my int $n = 10; say [+] ^$n,$n' 55

Enjoy, Have FUN! H.Merijn