| Bytes | Lang | Time | Link |
|---|---|---|---|
| 096 | Tcl | 210304T213308Z | sergiol |
| 019 | Juby | 250429T152431Z | Jordan |
| 013 | cQuents | 171012T010742Z | Stephen |
| 007 | Vyxal 3 | 250225T111534Z | Themooni |
| 050 | Desmos | 250225T052910Z | DesmosEn |
| 110 | Tcl | 210304T064320Z | wolfhamm |
| 004 | MathGolf | 220415T135015Z | Kevin Cr |
| 043 | Factor + math.unicode | 220414T185535Z | chunes |
| 081 | tinylisp | 220304T152355Z | Giuseppe |
| 004 | Vyxal | 220304T192612Z | Seggan |
| 028 | Charcoal | 220304T141626Z | jixperso |
| 007 | Vyxal | 210519T095756Z | emanresu |
| 044 | Javascript | 171011T233951Z | SuperSto |
| 076 | Lua | 210303T004026Z | J. А. de |
| 005 | Stax | 210302T195657Z | user8965 |
| 043 | Whispers v3 | 210204T154629Z | Razetime |
| 062 | Setanta | 210204T234409Z | bb94 |
| 018 | APL Dyalog Unicode | 201220T133743Z | Kamila S |
| 065 | Common Lisp | 180223T182428Z | Renzo |
| 035 | Ruby | 160801T091000Z | Sherlock |
| 004 | 05AB1E | 170105T155726Z | Magic Oc |
| 007 | Japt | 180220T093507Z | Shaggy |
| 004 | Jelly | 180220T022201Z | chromati |
| 003 | Pyt | 180218T052804Z | qqq |
| 084 | Scala | 180203T153827Z | oowekyal |
| 603 | Brainfuck | 160731T213953Z | primo |
| 005 | Pyt | 171227T224840Z | mudkip20 |
| 118 | Fortran 95 | 171229T133459Z | Thiago O |
| 030 | J | 171229T020319Z | Bolce Bu |
| 004 | Husk | 171228T001750Z | ბიმო |
| 054 | BrainFlak | 171012T014535Z | Nitrodon |
| 023 | Perl 6 | 171011T233515Z | Sean |
| 028 | dc | 160730T040823Z | juh |
| 034 | R | 170105T161400Z | rturnbul |
| 012 | Pushy | 161223T203506Z | FlipTack |
| 094 | C# 94 Bytes | 160811T225417Z | user1954 |
| 130 | Racket | 161015T051903Z | rnso |
| 362 | Lithp | 161115T004716Z | Andrakis |
| 140 | ForceLang | 160815T134020Z | SuperJed |
| 036 | DC GNU or OpenBSD flavour | 160730T120658Z | user1921 |
| 046 | JavaScript ES6 | 160730T112737Z | c.P.u1 |
| 039 | Javascript ES6 | 160730T053750Z | Pandacod |
| 034 | Fourier | 160815T123651Z | Beta Dec |
| 012 | 05AB1E | 160815T123129Z | Emigna |
| 031 | Brachylog | 160811T184105Z | Leaky Nu |
| 165 | Java | 160811T182722Z | user1893 |
| 4948 | R | 160805T175359Z | user5957 |
| 068 | Swift | 160810T231557Z | Alexande |
| 066 | R | 160801T122926Z | Rudier |
| 045 | Python | 160730T040138Z | primo |
| 086 | PowerShell v3+ | 160805T193504Z | AdmBorkB |
| 016 | J | 160730T141738Z | Dan Oak |
| 055 | Forth | 160801T172433Z | mbomb007 |
| 040 | Maple | 160801T140515Z | DSkoog |
| 070 | Clojure | 160801T095241Z | user1697 |
| 006 | Jelly | 160730T033357Z | Dennis |
| 008 | Jelly | 160801T023838Z | miles |
| 020 | ngn/apl | 160731T221230Z | miles |
| 005 | Pyke | 160731T115606Z | Blue |
| 039 | Python 2 | 160730T163410Z | Dennis |
| 100 | BrainFlak | 160730T070837Z | Wheat Wi |
| 024 | Mathematica | 160730T070728Z | DavidC |
| 039 | Ruby | 160730T111631Z | lynn |
| 036 | Julia | 160730T110325Z | lynn |
| 004 | Actually | 160730T093955Z | Adnan |
| 029 | Haskell 29 Bytes | 160730T080846Z | Christia |
| 085 | Ruby | 160730T084935Z | Seims |
| 028 | GAP 28 Bytes | 160730T083634Z | Christia |
| 010 | Mathematica | 160730T083932Z | Martin E |
| 026 | Mathematica | 160730T073220Z | Yytsi |
| 029 | PARI/GP | 160730T043246Z | primo |
| 013 | Pyth | 160730T042830Z | izzyg |
Tcl, 96 bytes
proc F x {expr $x>1?\[F $x-1]+\[F $x-2]:$x}
proc P x {time {append p *[F [incr i]]} $x
expr 1$p}
J-uby, 19 bytes
:+|:/&:*%(:++[0,1])
Explanation
:+ | :/ & :* % (:+ + [0, 1])
:+ | # Range 1..input, then
:/ & # Reduce with...
:* % ( ) # Product with...
:+ + [0, 1] # Fibonacci number
cQuents, 16 15 13 bytes
=1:Zb$
=1:Z+Y
Explanation
=1: Sequence with first term = 1
Zb$ Each term equals the previous times the next line at the current index
=1: Sequence with first term = 1
Z+Y Each term equals the previous two terms added together
Vyxal 3, 7 bytes
-2 bytes by weird glyphs
k±⎄+}⊖Π
k±⎄+}⊖Π
⊖ # take the first n where n is implicit input and the list is:
k±⎄+} # fibonacci generator
⎄ } # generate an infinite list
+ # with addition
k± # and starting point [1,1]
Π # product of the resulting array
💎
Created with the help of Luminespire.
Desmos, 50 bytes
r(n)=\{n<3:1,r(n-1)+r(n-2)\}
g(k)=∏_{n=1}^kr(n)
This recursively defines the Fibonacci series, with the base cases (any n<3) are set to 1. It then uses the ∏ to take the product of the series for n=1 to k.
Desmos doesn't allow for integers as large as generated by the k=100 case, so it returns undefined, but the idea of the program would generate the proper number within 5 seconds given enough memory, so I think this is valid.
Tcl, 110 bytes
set a 0
set b [incr x]
time {set c [expr $a+$b]
set a $b
set x [expr $x*[set b $c]]} [expr {*}$argv-1]
puts $x
Was able to take off 9 bytes thanks to sergiol!
MathGolf, 4 bytes
╒fε*
Explanation:
╒ # Push a list in the range [1, (implicit) input]
f # Convert each to its Fibonacci value
ε* # Get the product of this list; reduce by multiplication
# (after which the entire stack is output implicitly as result)
tinylisp, 83 81 bytes
(load library
(d F(q((N)(i(l N 3)1(a(F(s N 1))(F(s N 2
(d P(q((N)(product(map F(0to N
-2 bytes thanks to DLosc for reminding me to remove parentheses.
tinylisp, 108 bytes
(d F(q((N)(i(l N 3)1(a(F(s N 1))(F(s N 2
(d M(q((A B)(i A(a B(M(s A 1)B))0
(d P(q((N)(i N(M(F N)(P(s N 1)))1
Exceeds the maximum recursion depth around N=14.
Vyxal, 4 bytes
ÞFẎΠ
Come on Vyxal, you can do better.
ÞFẎΠ # Takes a number input
ÞF # Infinite Fibonacci numbers
Ẏ # Limit to first n numbers
Π # Product of them
Vyxal, 7 bytes
ƛÞF$i;Π
Vyxal r, 6 bytes
ƛÞFi;Π
# implicit input
ƛ ; # Lambda map (1...input inclusive)
ÞF # All fibbonacci numbers
$ # Swap stack
i # Item
Π # Reduce by product
# Implicit output
With r, all functions take arguments in reverse, so $ is not needed.
Lua, 76 bytes
Naïve solution (works until 14)
function I(x,a,b,c)return x<1 and c or I(x-1,a+b,a,a*c)end print(I(z,1,0,1))
Arbitrary-precision solution, using lua-nums (94 bytes)
--nums.bn is the name of the library as obtained from Luarocks
function I(x,a,b,c)return x<1 and c or I(x-1,a+b,require"nums.bn"(a),a*c)end print(I(z,1,0,1))
(Obviously you could rename the library in order to have shorter code, but this smells like cheating).
Timings for the second solution are:
real 0m0,030s
user 0m0,028s
sys 0m0,000s
Stax, 5 bytes
Æn─⌂▄
Run and debug it Unpacked it's
vOF|5*
v decrement input by 1
O tuck 1 under top value of stack (in case input was one)
F turns rest of loop into a for loop for 1..(input-1)
|5 get F(i+1)
* multiply by running product
Whispers v3, 43 bytes
> Input
> fₙ
>> 2ᶠ1
>> ∏3
>> Output 4
Needs to be run with
python3 whispers\ v3.py fibonacciorial.wisp < input.txt 2> /dev/null
Finishes well within 5 seconds on repl.it.
Setanta, 65 62 bytes
gniomh(n){a:=0b:=1x:=1le i idir(0,n){b+=a a=b-a x*=a}toradh x}
Unfortunately isn't exact because this language doesn't have bigints.
APL (Dyalog Unicode), 18 bytes
×/(+.!∘⌽⍨∘⍳¨1+∘⍳⊢)
Explanation:
×/(+.!∘⌽⍨∘⍳¨1+∘⍳⊢)
1+∘⍳⊢ ⍝ generate numbers 2-(⍵+1)
¨ ⍝ ... map to each
+.!∘⌽⍨∘⍳ ⍝ n-th fibonacci number
×/ ⍝ product of all
Fibonacci formula explanation:
+.!∘⌽⍨∘⍳
⍳ ⍝ numbers 1 to ⍵
⍨ ⍝ apply to both sides of +.!∘⌽
⌽ ⍝ reverse the ⍵ vector.
+.! ⍝ inner product: sum and binomial
Common Lisp, 65 bytes
(defun f(n &optional(a 1)(b 1))(if(< n 1)1(*(f(1- n)b(+ a b))a)))
Another port of Dennis's Python answer.
The straight iterative implementation is four bytes more:
(lambda(n)(do((x 1 y)(y 1(+ x y))(i 0(1+ i))(p 1(* p x)))((= i n)p)))
Ruby, 35 bytes
A Ruby fork of Dennis's Python answer. Golfing suggestions welcome.
f=->n,a=1,b=1{n<1?1:a*f[n-1,b,a+b]}
Ungolfed:
def f(n)
a=b=z=1
(1..n).each do |i|
z*=a
a,b=b,a+b
end
return z
end
Japt, 7 bytes
õ@MgXÃ×
Explanation
õ :Range [1,input]
@ Ã :Pass each X through a function
MgX : Xth Fibonacci number
× :Reduce by multiplication
Pyt, 3 bytes
Zero indexed
Thanks to mudkip201 for catching my mistake
řḞΠ
implicit input
ř range from input to one
Ḟ fibonacci over array
Π product
implicit output
Scala, 84 bytes
def f(i:Int,v:BigInt=1,p:BigInt=0,c:BigInt=1):BigInt=if(i==0)c else f(i-1,v+p,v,c*v)
Tail recursive function, based on this Fibonnaci implementation. This version adds a parameter to keep track of the running product.
Run it online (with test cases)
Brainfuck, 1198 1067 817 770 741 657 611 603
,[>++++++[-<-------->]<<[->++++++++++<]>>,]>+>+>>+>+<<<<<<[->>>[[-]
<[->+<]>>[-<+<+>>]<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->
[-]>>>>>>+>+<<<<<<<<[->+<]]]]]]]]]]]+>>>>>>>>]<<<<<<<<[->[-<+<<+>>>
]<[->+<]>>>[<<<<<[->>>>>>>>+<<<<<<<<]>>>>>>>>>>>>>]<<<<<<<<[->>>[-<
<<<<<<<+>>>>[->+>>+<<<]>[-<+>]>>>]<<[->>>>>>>+>+<<<<<<<<]<+<<<<<<<<
]>>>[-]>>>>>[[-]>[->+<]>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<
+>[->>>>>>+>+<<<<<<<<[-]]]]]]]]]]>]<<[<]+>>>>>>>>]<<<<<<<<[<<<<<<<<
]>>>>>[>>>>>>>>]+<<<<<<<<]>>>>>>>>>>>[<[-]>>[-<<+>>]>>>>>>>]<<<<<<<
<[<<<<<<<<]>>]>>>>>>[>>>>>>>>]<<<<<<<<[+++++[-<++++++++>]<.<<<<<<<]
Uncompressed, with comments:
# parse input (max 255)
,[>++++++[-<-------->]<<[->++++++++++<]>>,]
>+>+>>+>+<<<<<<
[->>>
# compute next fibonacci number
[[-]<
[->+<]>>
[-<+<+>>]<
# perform carries
[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<
[->[-]>>>>>>+>+<<<<<<<<[->+<]]
]]]]]]]]]+>>>>>>>>
]<<<<<<<<
# multiplication
[->
# extract next digit of F_n (most significant first)
[-<+<<+>>>]<
[->+<]>>>
# move back to the end
[<<<<<
[->>>>>>>>+<<<<<<<<]>>>>>>>>>>>>>
]<<<<<<<<
# digit wise multiplication (shifting current digit)
[->>>
[-<<<<<<<<+>>>>
[->+>>+<<<]>
[-<+>]>>>
]<<
# shift previous total over one gap (in effect multiplying by 10)
[->>>>>>>+>+<<<<<<<<]<+<<<<<<<<
]>>>[-]>>>>>
# add product to total
[[-]>
[->+<]>
# perform carries
[-<+>
[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>
[->>>>>>+>+<<<<<<<<[-]]
]]]]]]]]>
]<<[<]+>>>>>>>>
]<<<<<<<<
[<<<<<<<<]>>>>>
[>>>>>>>>]+<<<<<<<<
]>>>>>>>>>>>
# overwrite previous product
[<[-]>>
[-<<+>>]>>>>>>>
]<<<<<<<<
[<<<<<<<<]>>
]>>>>>>
# output product
[>>>>>>>>]<<<<<<<<
[+++++
[-<++++++++>]<.<<<<<<<
]
Runtime for n = 100 is less than 1 second with the online interpreter (about 0.2s locally using my own interpreter). Maximum input is 255, but would require the interpreter to support ~54000 cells (the online interpreter seems to wrap on 64k).
Change Log
Saved around 130 bytes with better extraction of the current digit to multiply through by, and by merging add and carry into a single pass. It also seems to be a bit faster.
Saved another 250 bytes. I managed to reduce my multiplication scratch pad by two cells, which saves bytes just about everywhere by not having to shift so far between digits. I also dropped the carry after multiplying through by a digit, and instead perform a full carry whilst adding to the running total.
Chopped another 50, again with better extraction of the current digit to multiply through by, simply by not moving it forward the first iteration, and working from where it is. A few micro-optimization further down account for around ~10 bytes.
30 more gone. Marking digits that have already been taken with a 0 rather than a 1 makes them easier to locate. It also makes the check if the multiplication loop has finished somewhat simpler.
I reduced the scratch pad by another cell, for 80 more bytes. I did this by merging the marker for the previous product and the current running total, which reduces the shifts between gaps, and makes bookkeeping a bit easier.
Saved another 50, by eliminating yet another cell, reusing the marker for fibonacci digits to mark the last digit taken as well. I was also able to merge the loop to shift the previous totals with the digit-wise multiplication loop.
Saved 8 bytes on input parsing. Oops.
Pyt, 5 bytes
←ř⁻ḞΠ
Input is from stdin. Approximately instantaneous for n=100. Takes less than a second for n=1000.
Explanation:
← Get input
ř Get [1,2,...,input]
⁻ Decrement all elements by 1
Ḟ Get Fibonacci numbers
Π Product
Fortran 95, 118 bytes
This version explicitly declares P as an integer, thus the limit is given by the size of the integer (4 bytes by default).
program o
integer,parameter::n=20
integer F(n),P
P=1
F(:2)=1
do i=3,n
F(i)=F(i-1)+F(i-2)
P=P*F(i)
enddo
print*,P
end
If I extend the size of the integer to 16 bytes, the byte count of the code increases by 3: integer*16 F(n),P.
One can also omit P from the declaration and use it as a 4 byte floating point, then the byte count is reduced by 2.
J, 30 Bytes
*/@:([{.(,{:+{:@}:)@]^:[&1 1x)
Probably improvable.
Explanation:
*/@:( ) | Product of
[{. | First n
(,{:+{:@}:)@]^:[&1 1x | n+2 fibonacci numbers:
&1 1x | Apply with the list 1 1 (x specifies extended prescision)
^:[ | n times:
(,{:+{:@}:)@] | Append the sum of the last two numbers
Computes the Fibonacc-orial of 100 in 2 ms.
Husk, 4 bytes
Π↑İf
Explanation
Π↑İf -- input is an integer N, for example 5
İf -- fibonacci numbers: [1,1,2,3,5,8,13,21,34…]
↑ -- take N: [1,1,2,3,5]
Π -- product: 30
Brain-Flak, 54 bytes
([{}]<(())>){(({})()<{({}()<([({})]({}{}))>)}{}{}>)}{}
Multiplication in Brain-Flak takes a long time for large inputs. Just multiplying F100 by F99 with a generic multiplication algorithm would take billions of years.
Fortunately, there's a faster way. A generalized Fibonacci sequence starting with (k, 0) will generate the same terms as the usual sequence, multiplied by k. Using this observation, Brain-Flak can multiply by a Fibonacci number just as easily as it can generate Fibonacci numbers.
If the stack consists of -n followed by two numbers, {({}()<([({})]({}{}))>)}{}{} will computen iterations of the generalized Fibonacci sequence and discard all by the last. The rest of the program just sets up the initial 1 and loops through this for all numbers in the range n...1.
Here's the same algorithm in the other languages provided by this interpreter:
Brain-Flak Classic, 52 bytes
({}<(())>){(({})[]<{({}[]<(({}<>)<>{}<>)>)}{}{}>)}{}
Brain-Flueue, 58 bytes
<>(<(())>)<>{(({}<>)<{({}({}))({}[()])}{}>[()]<>)}<>({}){}
Mini-Flak, 62 bytes
([{}()](())){(({})()({({}()([({})]({}{}))[({})])}{}{})[{}])}{}
Perl 6, 23 bytes
{[*] (1,&[+]...*)[^$_]}
1, &[+] ... *is the infinite Fibonacci sequence.[^$_]takes the first$_elements of the sequence, where$_is the argument to the function.[*]reduces that subsequence with multiplication.
dc, 38 40 30 28 bytes
?si1d[sadlarla+zli>b]sbzli>b[*z1<*]ds*xf
si1d[sadlarla+zli>b*]sbzli>b
Expanded:
si # Take input from top of stack and store it in register `i'
1d # Push 1 on stack and duplicate
[ # Open macro definition
sa # Store most recent term of Fibonacci sequence in register `a'
d # Duplicate second most recent term
la # Push most recent term onto stack
r # Rotate top two items on stack
la # Push most recent term onto stack (again)
# At this point, we've essentially duplicated the top two terms of the stack
# without altering the order of the terms
+ # Add top two terms of stack (generate next Fibonacci number)
zli>b # Take stack depth and load input (target number of terms); if we don't have
# enough terms yet, execute `b'
* # Once we've generated all the terms (factors, really), we'll multiply
# them, one * for every time we iterated to generate a term
]sb # Store macro in register `b'
zli>b # Look familiar? This way, we change the "do-while" (`dsbx') to just "while"
# Leave result on top of stack
R, 36 34 bytes
prod(numbers::fibonacci(scan(),T))
Takes input from stdin. -2 bytes due to @Jardo Dubbeldam.
Pushy, 12 bytes
1&{2-:2d+;P#
This is a straightforward implementation of the specification:
1& \ Push 1, twice.
{ \ Shift stack left (so input is on top).
\ Stack: [1, 1, n]
2-: \ Input - 2 times do (this consume input):
2d+; \ Push the sum of the last 2 values.
\ Stack: [fib(1), fib(2)... fib(n)]
P# \ Output the stack product.
C# 110 109 107 103 101 94 Bytes
using i=System.Numerics.BigInteger;i f(i n){i a=0,b=1,x=1;for(;n-->0;)x*=a=(b+=a)-a;return x;}
Explanation
//Aliasing BigInteger saves a few bytes
using i=System.Numerics.BigInteger;
//Since BigInteger has an implicit from int we can also change the input
//and save two more bytes.
i f(i n)
{
//using an alternative iterative algorithm (link to source below) to cut out the temp variable
//b is next iteration, a is current iteration, and x is the running product
i a = 0, b = 1, x = 1;
//post decrement n down to zero instead of creating a loop variable
for (; n-- > 0;)
//The bracket portion sets the next iteration
//get the current iteration and update our running product
x *= a = (b += a) - a;
return x;
}
Racket 130 bytes
(define(fb n)(cond[(or(= n 1)(= n 2))1][(+(fb(- n 1))(fb(- n 2)))]))
(define(fo n)(for/product((i(range 1(+ 1 n))))(fb i)))(fo n))
Ungolfed:
(define (f n)
(define (fibonacci n)
(cond
[(or (= n 1)(= n 2)) 1]
[else (+ (fibonacci (- n 1)) (fibonacci(- n 2)))] ))
(define (f_orial n)
(for/product ((i (range 1 (add1 n))))
(fibonacci i)))
(f_orial n))
Testing:
(f 1)
(f 2)
(f 3)
(f 4)
(f 5)
(f 6)
(f 7)
(f 8)
(f 9)
(f 10)
(f 11)
(f 12)
(f 20)
(f 30)
Output:
1
1
2
6
30
240
3120
65520
2227680
122522400
10904493600
1570247078400
9692987370815489224102512784450560000
607373569868916007005878071331449502263924414704952629297115029592606043656028160000000
Lithp, 362 bytes
(
(platform v1)
(import "lists")
(var FL (dict))
(def fib #N::((if (< N 2) (1) ((+ (fibFL (- N 1)) (fibFL (- N 2)))))))
(def fibFL #N::((if (dict-present FL N) ((dict-get FL N)) ((var I (fib N)) (set FL (dict-set FL N I)) (I)))))
(def fib-orial #N::((prod (map (seq 1 N) (scope #I::((fib I)))))))
(each (seq 2 15) (scope #N :: ((print (fib-orial N)))))
)
As with the JavaScript answer, rounding errors occur at orial of 16. Therefore this program prints the orial of 2 to 15.
This one was tricky, because the run time was well over 10 seconds for even a small number.
I solved this by using a dictionary to store results of calls to fib. The result is that instead of 10 seconds and over 100,000 function calls, the code often runs in under 200ms and results in only ~6700 function calls.
ForceLang, 140 bytes
def s set
s a 0
s b s p 1
s k io.readnum()
if k=1
goto b
label a
s c a+b
s a b
s b c
s p p.mult c
s k k+-1
if k+-1
goto a
label b
io.write p
DC (GNU or OpenBSD flavour), 36 bytes
File A003266-v2.dc:
0sA1sB1?[1-d0<LrlBdlA+sBdsA*r]dsLxrp
(no trailing newline)
...now the result is held on the stack instead of using a named register (is Y in version 1). The r command is not available in the original dc (see RosettaCode's Dc page).
Run:
$ time dc -f A003266-v2.dc <<< 100
337160185314646812538696406544757668982800617293741131066248697780154\
067113858986861650083419002906758366518229170155317201108257458743138\
231009903039430687777564739516714333248356092511296002464445971530050\
748123505611143429361903834745639045420958710122526175737166644906862\
503399957355216552452972546762806017088660200107713761380302715864832\
933550772869860576999281875676563330531852996518618404399969665040724\
619325787756882524564612936699407973972069814744031077387126963975233\
435649367891342439056453538921224003889562681162794913297808607025508\
266839229003714114129148483959669418215206272639036409444764264391237\
153249138808963484599594192808965375167268874071815206410716935739946\
647337580497226059476896995250734669418905023382359631646757058443412\
805239889122373033501909297493561702963891935828612435071136036127915\
741683742890415005429240675631783758284059633136358120778179307093676\
578662977299983285725734969609441661625997430420875699783536070284091\
2518532683324936435856348020736000000000000000000000000
real 0m0.005s
user 0m0.004s
sys 0m0.000s
Trying to explain:
tos is the contents of the top of the stack without removing it.
nos is the element below tos.
0 sA # push(0) ; A=pop()
1 sB # push(1) ; B=pop()
1 # push(1)
# this stack position will incrementally hold the product
? # push( get user input and evaluate it )
[ # start string
1- # push(pop()-1)
d # push(tos)
0 # push(0)
<L # if pop() < pop() then evaluate contents of register L
r # exchange tos and nos
# now nos is the loop counter
# and tos is the bucket for the product of the fibonacci numbers
lB # push(B)
d # push(tos)
lA # push(A)
+ # push(pop()+pop())
# now tos is A+B, nos still is B
sB # B=pop()
# completes B=A+B
d # push(tos)
sA # A=pop()
# completes B=A
# tos (duplicated new A from above) is the next fibonacci number
* # push(nos*tos)
# tos now is the product of all fibonacci numbers calculated so far
r # exchange tos and nos
# now tos is the loop counter, nos is the product bucket
] # end string and push it
d # push(tos)
sL # L=pop()
x # evaluate(pop())
r # exchange tos and nos
# nos now is the former loop counter
# tos now is the complete product. \o/
p # print(tos)
# this does not pop() but who cares? :-P
DC, 41 bytes
...straight forward, no tricks:
File A003266-v1.dc:
0sA1sB1sY?[1-d0<LlBdlA+sBdsAlY*sY]dsLxlYp
(no trailing newline)
Run:
$ for i in $(seq 4) ; do dc -f A003266-v1.dc <<< $i ; done
1
1
2
6
$ time dc -f A003266-v1.dc <<< 100
337160185314646812538696406544757668982800617293741131066248697780154\
067113858986861650083419002906758366518229170155317201108257458743138\
231009903039430687777564739516714333248356092511296002464445971530050\
748123505611143429361903834745639045420958710122526175737166644906862\
503399957355216552452972546762806017088660200107713761380302715864832\
933550772869860576999281875676563330531852996518618404399969665040724\
619325787756882524564612936699407973972069814744031077387126963975233\
435649367891342439056453538921224003889562681162794913297808607025508\
266839229003714114129148483959669418215206272639036409444764264391237\
153249138808963484599594192808965375167268874071815206410716935739946\
647337580497226059476896995250734669418905023382359631646757058443412\
805239889122373033501909297493561702963891935828612435071136036127915\
741683742890415005429240675631783758284059633136358120778179307093676\
578662977299983285725734969609441661625997430420875699783536070284091\
2518532683324936435856348020736000000000000000000000000
real 0m0.006s
user 0m0.004s
sys 0m0.004s
JavaScript (ES6), 46 bytes
f=(n,a=1,b=1,c=i=1)=>n==i?c:f(n,b,a+b,c*b,++i)
Uses recursion and accumulator variables. Rounding errors start at f(16).
Javascript (ES6), 51 39 bytes
Recursive implementation (39 bytes)
f=(n,a=p=i=b=1)=>++i<n?f(n,b,p*=b+=a):p
Original implementation (51 bytes)
n=>{for(i=a=b=p=1;++i<n;){c=a;a=b;p*=b+=c}return p}
Note: Starts rounding errors for the Fibonacci-orial of 16, 100 is just Infinity, runs in what appears to be <1 second.
Fourier, 34 bytes
Basically, just a small tweak of the Fibonacci sequence program on Fourier's esolangs page.
1~F~x~yI~k(x*F~Fy+x~gy~xg~yi^~i)Fo
If you want to try this program online, I would suggest using Dennis' site, http://fourier.tryitonline.net, because on http://labs.turbo.run/beta/fourier an input of 100 leads to an output of infinity.
05AB1E, 12 bytes
X$ÍF‚D`ŠŠO}P
Explanation
X$ # push 1, 1, input
ÍF } # input-2 times do:
‚D # pair top 2 elments and duplicate
`ŠŠ # flatten one pair and move the remaining pair to the top of the stack
O # sum the pair
P # product of stack
# implicitly print
Java, 165 bytes
Golfed:
BigInteger f(int n){BigInteger[]a={BigInteger.ZERO,BigInteger.ONE,BigInteger.ONE};for(int i=0;i<n;){a[++i%2]=a[0].add(a[1]);a[2]=a[2].multiply(a[i%2]);}return a[2];}
This is yet another case where BigInteger being required due to large numbers. However, I was able to keep the text BigInteger to a minimum, keeping the size down. I also compared with static imports, and it made the total length longer.
This program works by tracking three numbers in an array. The first two are the previous two Fibonacci numbers. The third is the accumulated value. The loop starts out by calculating the next value and storing it in alternating (0, 1, 0, 1, ...) array indices. This avoids needing to shift values with costly (in terms of source size) assignment operations. Then grab that new value and multiply it into the accumulator.
By avoiding temporary objects and limiting the loop to two assignment operators, I was able to squeeze out quite a few bytes.
Ungolfed:
import java.math.BigInteger;
public class Fibonacci_orial {
public static void main(String[] args) {
// @formatter:off
String[][] testData = new String[][] {
{ "1", "1" },
{ "2", "1" },
{ "3", "2" },
{ "4", "6" },
{ "5", "30" },
{ "6", "240" },
{ "7", "3120" },
{ "8", "65520" },
{ "9", "2227680" },
{ "10", "122522400" },
{ "11", "10904493600" },
{ "12", "1570247078400" },
{ "13", "365867569267200" },
{ "14", "137932073613734400" },
{ "15", "84138564904377984000" },
{ "16", "83044763560621070208000" },
{ "17", "132622487406311849122176000" },
{ "18", "342696507457909818131702784000" },
{ "19", "1432814097681520949608649339904000" },
{ "20", "9692987370815489224102512784450560000" },
{ "100", "3371601853146468125386964065447576689828006172937411310662486977801540671138589868616500834190029067583665182291701553172011082574587431382310099030394306877775647395167143332483560925112960024644459715300507481235056111434293619038347456390454209587101225261757371666449068625033999573552165524529725467628060170886602001077137613803027158648329335507728698605769992818756765633305318529965186184043999696650407246193257877568825245646129366994079739720698147440310773871269639752334356493678913424390564535389212240038895626811627949132978086070255082668392290037141141291484839596694182152062726390364094447642643912371532491388089634845995941928089653751672688740718152064107169357399466473375804972260594768969952507346694189050233823596316467570584434128052398891223730335019092974935617029638919358286124350711360361279157416837428904150054292406756317837582840596331363581207781793070936765786629772999832857257349696094416616259974304208756997835360702840912518532683324936435856348020736000000000000000000000000" }
};
// @formatter:on
for (String[] data : testData) {
System.out.println("Input: " + data[0]);
System.out.println("Expected: " + data[1]);
System.out.print("Actual: ");
System.out.println(new Fibonacci_orial().f(Integer.parseInt(data[0])));
System.out.println();
}
}
// Begin golf
BigInteger f(int n) {
BigInteger[] a = { BigInteger.ZERO, BigInteger.ONE, BigInteger.ONE };
for (int i = 0; i < n;) {
a[++i % 2] = a[0].add(a[1]);
a[2] = a[2].multiply(a[i % 2]);
}
return a[2];
}
// End golf
}
Program output:
Input: 1
Expected: 1
Actual: 1
Input: 2
Expected: 1
Actual: 1
Input: 3
Expected: 2
Actual: 2
Input: 4
Expected: 6
Actual: 6
Input: 5
Expected: 30
Actual: 30
Input: 6
Expected: 240
Actual: 240
Input: 7
Expected: 3120
Actual: 3120
Input: 8
Expected: 65520
Actual: 65520
Input: 9
Expected: 2227680
Actual: 2227680
Input: 10
Expected: 122522400
Actual: 122522400
Input: 11
Expected: 10904493600
Actual: 10904493600
Input: 12
Expected: 1570247078400
Actual: 1570247078400
Input: 13
Expected: 365867569267200
Actual: 365867569267200
Input: 14
Expected: 137932073613734400
Actual: 137932073613734400
Input: 15
Expected: 84138564904377984000
Actual: 84138564904377984000
Input: 16
Expected: 83044763560621070208000
Actual: 83044763560621070208000
Input: 17
Expected: 132622487406311849122176000
Actual: 132622487406311849122176000
Input: 18
Expected: 342696507457909818131702784000
Actual: 342696507457909818131702784000
Input: 19
Expected: 1432814097681520949608649339904000
Actual: 1432814097681520949608649339904000
Input: 20
Expected: 9692987370815489224102512784450560000
Actual: 9692987370815489224102512784450560000
Input: 100
Expected: 3371601853146468125386964065447576689828006172937411310662486977801540671138589868616500834190029067583665182291701553172011082574587431382310099030394306877775647395167143332483560925112960024644459715300507481235056111434293619038347456390454209587101225261757371666449068625033999573552165524529725467628060170886602001077137613803027158648329335507728698605769992818756765633305318529965186184043999696650407246193257877568825245646129366994079739720698147440310773871269639752334356493678913424390564535389212240038895626811627949132978086070255082668392290037141141291484839596694182152062726390364094447642643912371532491388089634845995941928089653751672688740718152064107169357399466473375804972260594768969952507346694189050233823596316467570584434128052398891223730335019092974935617029638919358286124350711360361279157416837428904150054292406756317837582840596331363581207781793070936765786629772999832857257349696094416616259974304208756997835360702840912518532683324936435856348020736000000000000000000000000
Actual: 3371601853146468125386964065447576689828006172937411310662486977801540671138589868616500834190029067583665182291701553172011082574587431382310099030394306877775647395167143332483560925112960024644459715300507481235056111434293619038347456390454209587101225261757371666449068625033999573552165524529725467628060170886602001077137613803027158648329335507728698605769992818756765633305318529965186184043999696650407246193257877568825245646129366994079739720698147440310773871269639752334356493678913424390564535389212240038895626811627949132978086070255082668392290037141141291484839596694182152062726390364094447642643912371532491388089634845995941928089653751672688740718152064107169357399466473375804972260594768969952507346694189050233823596316467570584434128052398891223730335019092974935617029638919358286124350711360361279157416837428904150054292406756317837582840596331363581207781793070936765786629772999832857257349696094416616259974304208756997835360702840912518532683324936435856348020736000000000000000000000000
R, 82, 53, 49 bytes (48 bytes w/ different input style)
b=d=1;a=0;for(i in 1:scan()){d=d*b;b=a+b;a=b-a};d
If we can just precede the code with the input number, we get the 48 byte
->n;b=d=1;a=0;for(i in 1:n){d=d*b;b=a+b;a=b-a};d
EDIT: New code. Original is below:
a=function(n)ifelse(n<3,1,{v=c(1,1,3:n);for(i in 3:n)v[i]=v[i-1]+v[i-2];prod(v)})
Won't return anything other than Inf for a(100) though. And it won't work for anything but non-negative integers.
Ungolfed:
a=function(n){
if(n<3) return(1)
v=c(1,1,3:n)
for(i in 3:n)
v[i]=v[i-1]+v[i-2]
prod(v)
}
Swift, 68 Bytes
func f(n:Int,_ a:Int=1,_ b:Int=1)->Int{return n<1 ?1:a*f(n-1,b,a+b)}
R, 99 96 78 76 66 bytes
This answer is uses Binet's Formula, as well as the prod(x)function. Since R doesn't have a build-in Phi value, I defined it myself :
p=(1+sqrt(5))/2;x=1;for(n in 1:scan())x=x*(p^n-(-1/p)^n)/sqrt(5);x
It works under 5 seconds, but R tends to give Inf as an answer for those big numbers...
Ungolfed :
r=sqrt(5)
p=(1+r)/2
x=1
for(n in 1:scan())
x=x*(p^n-(-1/p)^n)/r
x
-2 bytes thanks to @Cyoce !
Oh, do I love this site ! -10 bytes thanks to @user5957401
Python, 45 Bytes
a=b=o=1
exec"o*=a;a,b=b,a+b;"*input()
print o
Input is taken from stdin. Output for n = 100 finishes too quickly to accurately time. n = 1000 takes approximately 1s.
Sample Usage
$ echo 10 | python fib-orial.py
122522400
$ echo 100 | python fib-orial.py
3371601853146468125386964065447576689828006172937411310662486977801540671138589868616500834190029067583665182291701553172011082574587431382310099030394306877775647395167143332483560925112960024644459715300507481235056111434293619038347456390454209587101225261757371666449068625033999573552165524529725467628060170886602001077137613803027158648329335507728698605769992818756765633305318529965186184043999696650407246193257877568825245646129366994079739720698147440310773871269639752334356493678913424390564535389212240038895626811627949132978086070255082668392290037141141291484839596694182152062726390364094447642643912371532491388089634845995941928089653751672688740718152064107169357399466473375804972260594768969952507346694189050233823596316467570584434128052398891223730335019092974935617029638919358286124350711360361279157416837428904150054292406756317837582840596331363581207781793070936765786629772999832857257349696094416616259974304208756997835360702840912518532683324936435856348020736000000000000000000000000
PowerShell v3+, 86 bytes
param($n)$f=,1*$n;2..$n|%{$f[$_]=$f[$_-1]+$f[$_-2]};"[bigint]"+($f[0..$n]-join'*')|iex
The [bigint] data structure was introduced in .NET Framework 4, hence the PowerShell v3+ requirement.
Takes input $n, constructs a new array $f pre-populated with 1s, of length $n. Then we loop from 2..$n and each iteration simply construct the next Fibonacci value. Finally, we take $f from 0 up to $n and -join it together with * (so we have a big ol' string like 1*1*2*3*5*8*...), prepend that string with the cast "[bigint]", and pipe that to |iex (short for Invoke-Expression and similar to eval). The result is left on the pipeline, and output is implicit. We get by with only one data cast, as PowerShell uses the explicit cast from the left-hand-side of an operator as an implicit cast on the right-hand-side.
Tosses an array-index-out-of-bounds style exception to STDERR, but that's shorter than setting the loop to 2..($n-1) ;-)
If we didn't need to go higher than ~55, we can get rid of the cast and parens for the following at 73 bytes. Input values above 13 will result in scientific notation output.
param($n)$f=,1*$n;2..$n|%{$f[$_]=$f[$_-1]+$f[$_-2]};$f[0..$n]-join'*'|iex
J, 17 16 bytes
1 byte is golfed with even better solution by miles.
[:*/+/@(!|.)\@i.
The idea is the same as the original but instead of forming the matrix to operate on minor diagonals we form the diagonals on the fly.
Original
To get the first n fibonomials:
*/\(#{.+//.)!/~i.
Reading right to left...
Create the array of consecutive integers (i.) up to specified one, from that array create the table (/~) of binomial coefficients (!) calculated from every pair in the array, this table is Pascal's triangle top of whlocated at the end of the first row and all elements under the main diagonal are 0, thankfully to implementation of !. If you sum (+/) all minor diagonals (/.), you get Fibonacci numbers, but you need to take ({.) as much of first elements from the resulting array as the length (#) of the table itself. Then the product (*/) applied to consecutive prefixes (\) of the array results into desired sequence of fibonorials. If you wish you can take only the last one using 2 more bytes ({:) but I thought that displaying all of them is not a sin :).
NB. the previous code block is not a J function.
{:*/\(#{.+//.)!/~i. 10
122522400
For big numbers in J you use x at the end:
{:*/\(#{.+//.)!/~i. 100x
3371601853146468125386964065447576689828006172937411310662486977801540671138589868616500834190029067583665182291701553172011082574587431382310099030394306877775647395167143332483560925112960024644459715300507481235056111434293619038347456390454209587101225...
The program runs on avarage 0.11s.
100 timex '{:*/\(#{.+//.)!/~i.100x'
0.112124
Forth, 55 bytes
Uses an iterative approach, built upon my Fibonacci answer in Forth. The results overflow arithmetically for n > 10. The answer is case-insensitive.
: f >r 1 1 r@ 0 DO 2dup + LOOP 2drop 1 r> 0 DO * LOOP ;
Maple, 40 bytes
`*`~(seq(combinat:-fibonacci(i),i=1..n))
Usage
> f:=n->`*`~(seq(combinat:-fibonacci(i),i=1..n));
> f(10);
122522400
This uses the built-in combinat:-fibonacci as well as the element-wise operator ~ to multiply the terms in the sequence.
Clojure, 70 bytes
Clojure isn't really a good language for code golf. Oh well.
Try it at http://tryclj.com.
(last(nth(iterate(fn[[a b r]][b(+ a b)(* r(+ a b))])[0N 1 1])(dec n)))
Jelly, 6 bytes
+С1ḊP
Input 100 finishes in 500 ms locally. Try it online!
How it works
+С1ḊP Niladic link. No input.
Since the link doesn't start with a nilad, the argument 0 is used.
1 Yield 1.
+ Add the left and right argument.
С Read a number n from STDIN.
Repeatedly call the dyadic link +, updating the right argument with
the value of the left one, and the left one with the return value.
Collect all values of the left argument into an array.
Ḋ Dequeue; discard the first Fibonacci number (0).
P Product; multiply the remaining ones.
Jelly, 8 bytes
RḶUc$S€P
My first submission in Jelly. It's not as short as @Dennis' answer, but its only 2 bytes longer with a different method.
Locally, it requires about 400ms compared to 380ms with @Dennis' version for n = 100.
Explanation
RḶUc$S€P Input: n
R Generate the range [1, 2, ..., n]
For each value x in that range
Ḷ Create another range [0, 1, ..., x-1]
U Reverse that list
c Compute the binomial coefficients between each pair of values
$ Bind the last two links (Uc) as a monad
S€ Sum each list of binomial coefficients
This will give the first n Fibonacci numbers
P Take the product of those to compute the nth Fibonacci-orial
ngn/apl, 20 bytes
{×/(+/(!∘⌽⍨⍳))¨1+⍳⍵}
Explanation
{×/(+/(!∘⌽⍨⍳))¨1+⍳⍵} Input: n
⍵ Get n
⍳ Form the range [0, 1, ..., n-1]
1+ Add 1 to each to get [1, 2, ..., n]
¨ For each value x
⍳ Form the range [0, 1, ..., x-1]
⌽⍨ Reverse it to get [x-1, ..., 1, 0]
!∘ Find the binomial coefficient between each pair in the original
range and reversed range
+/ Reduce using addition to get the xth Fibonacci number
×/ Reduce using multiplication and return
Brain-Flak, 110 104 100 bytes
({}<((())<>)>){({}[()]<<>(({})<>({}<>)<>)>)}<>{}([[]]()){({}()<({}<>)<>({<({}[()])><>({})<>}{})>)}{}
Explanation
First we run an improved version of the Fibonacci sequence generator curtesy of Dr Green Eggs and Iron Man
({}<((())<>)>){({}[()]<<>(({})<>({}<>)<>)>)}<>{}
Then while the stack has more than one item on it
([[]]()){({}()<...>)}
multiply the top two items
({}<>)<>({<({}[()])><>({})<>}{})
and pop the extra zero
{}
Mathematica 25 24 bytes
With thanks to Martin Ender.
1##&@@Fibonacci@Range@#&
1##&@@Fibonacci@Range@#&@100
Timing: 63 microseconds.
{0.000063,
3371601853146468125386964065447576689828006172937411310662486977801540
6711385898686165008341900290675836651822917015531720110825745874313823
1009903039430687777564739516714333248356092511296002464445971530050748
1235056111434293619038347456390454209587101225261757371666449068625033
9995735521655245297254676280601708866020010771376138030271586483293355
0772869860576999281875676563330531852996518618404399969665040724619325
7877568825245646129366994079739720698147440310773871269639752334356493
6789134243905645353892122400388956268116279491329780860702550826683922
9003714114129148483959669418215206272639036409444764264391237153249138
8089634845995941928089653751672688740718152064107169357399466473375804
9722605947689699525073466941890502338235963164675705844341280523988912
2373033501909297493561702963891935828612435071136036127915741683742890
4150054292406756317837582840596331363581207781793070936765786629772999
8328572573496960944166162599743042087569978353607028409125185326833249
36435856348020736000000000000000000000000}
Ruby, 39 bytes
->n{f=i=b=1;n.times{f,i,b=i,f+i,b*f};b}
Julia, 36 bytes
!x=[([1 1;1 0]^n)[2]for n=1:x]|>prod
Actually, 4 bytes
Runs the input 100 within 0.2 seconds. Code:
R♂Fπ
Explanation:
R # Get the range [1, ..., input].
♂F # Map over the array with the fibonacci command.
π # Take the product.
Uses the CP-437 encoding. Try it online!.
Haskell 41 29 Bytes
1+11 bytes saved by @Laikoni's remarks.
f=1:scanl(+)1f
(scanl(*)1f!!)
1,f and !! are separate tokens.
The first lines defines the fibonacci sequence, the second is a function that computes the sequence of fibonacci-orials and returns the n-th for a given n. It starts printing digits almost immediately even for n=1000.
Ruby, 85 Bytes
g =->x{(1..x).to_a.collect{|y|(0..y).inject([1,0]){|(a,b),_|[b, a+b]}[0]}.inject(:*)}
Turned out fine, but there's probably a shorter solution.
Fast Fibonnaci calculation taken from here: link
GAP 28 Bytes
Didn't know before today that GAP has a Fibonacci builtin.
n->Product([1..n],Fibonacci)
Mathematica, 10 bytes
Fibonorial
Another Mathematica built-in soundly beaten by a golfing language without the built-in.
Mathematica - 32 26 bytes
Fibonacci@i~Product~{i,#}&
@MartinEnder chopped 6 bytes!
PARI/GP, 29 bytes
f=n->prod(i=1,n,fibonacci(i))
Or alternatively:
f=n->prod(i=a=!b=0,n,b=a+a=b)
Pyth, 13 bytes
u*Gs=[sZhZ)Q1
This employs a clever, non-typesafe trick. Five of the characters (u*G ... Q1) say that the output is the product of the input many numbers. The rest of the code generates the numbers.
=[sZhZ) updates the variable Z to the list [s(Z), h(Z)]. Then s sums that list, to be multiplied.
Z is initially 0. s, on ints, is the identity function. h, on its, is the + 1 function. So on the first iteration, Z becomes [0, 1]. s on lists is the sum function, as mentioned above. h is the head function. So the second iteration is [1, 0].
Here's a list:
Iter Z Sum
0 0 Not used
1 [0, 1] 1
2 [1, 0] 1
3 [1, 1] 2
4 [2, 1] 3
5 [3, 2] 5
These sums are multiplied up to give the result.