Skip to main content
3 of 4
added 7 characters in body
Andreas Louv
  • 1.7k
  • 13
  • 25

Perl 6, 52~72 47~67 bytes

This can properly be shorter:

sub a($n,$x){EVAL("1,"x$n~"+*"x$n~"...*")[^$x]}

Requires the module MONKEY-SEE-NO-EVAL, because of the following error:

===SORRY!=== Error while compiling -e
EVAL is a very dangerous function!!! (use MONKEY-SEE-NO-EVAL to override,
but only if you're VERY sure your data contains no injection attacks)
at -e:1

$ perl6 -MMONKEY-SEE-NO-EVAL -e'a(3,8).say;sub a($n,$x){EVAL("1,"x$n~"+*"x$n~"...*")[^$x]}'
(1 1 1 3 5 9 17 31)
Andreas Louv
  • 1.7k
  • 13
  • 25