in reply to How do I write a program that calculates the sum of all numbers to a number, n?
Just do it in a slightly more complicated manner than is strictly necessary...
#!/usr/bin/perl use strict; use warnings; use feature qw/say/; while(my $n = shift @ARGV) { say grep { $n == $_ } map { $n += $_ } map { $n-- } map { ($n) x $_ } $n ;}
|
|---|