### Re: Golf: Factorials

 on Apr 10, 2015 at 21:36 UTC ( #1123083=note: print w/replies, xml ) Need Help??

31 characters
\$a=1;print\$a*=\$b+=1,\$/for 0..10

Replies are listed 'Best First'.
Re^2: Golf: Factorials
by choroba (Bishop) on Apr 10, 2015 at 21:49 UTC
Easy to make it 30 with
```\$a=1;print\$a*=\$b+=1,\$/for a..k
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

24 characters using say and an unused punctuation variable:

```13:38 >perl -E "\$a=1;say\$a*=++\$}for a..k"
1
2
6
24
120
720
5040
40320
362880
3628800
39916800

13:38 >

:-)

 Athanasius <°(((>< contra mundum Iustus alius egestas vitae, eros Piratica,

Though we may have strayed a bit from the original golf, yours can be whittled by three strokes:

```> perl -E "\$a=1;say\$a*=++\$}for a..k"
> perl -E "say\$x*=\$_ for++\$x..11"

1
2
6
24
120
720
5040
40320
362880
3628800
39916800

also this solution works only for series of consecutive integers starting with 1
```perl -E "\$a=1;say\$a*=++\$}for @ARGV" 0 1 2 3
1
2
6
24
perl -E "\$a=1;say\$a*=++\$}for @ARGV" 1 3
1
2

L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Create A New User
Node Status?
node history
Node Type: note [id://1123083]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2019-10-18 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In 2019 the site I miss most is:

Results (45 votes). Check out past polls.

Notices?