New answers tagged

2

APL (Dyalog Unicode), 46 bytes {∧/0<⍵:⊃⊃⍸A⍷↑{⍵((+/↑),⊢)⍣{</+/¨A⍵}⍵⍴1}¨⍳⊃A←⌽⍵} Try it online! Anonymous prefix function, taking a vector of integers. How? ∧/0<⍵: ⍝ If the given sequence contains any non-positive integers, then return nothing. Otherwise... A←⌽⍵ ⍝ Set A to be the reverse of the given sequence {...}¨⍳⊃ ⍝ For each n in 1 to last ...


1

Javascript, 24 bytes - recursive version, 33 bytes - usage of Binet's formula, 46 bytes - continuous approximation with the "phi" itself Usage of "Binet's formula" and a bitwise "OR" operator to round the result. Originally in the "Binet's formula" you have to subtract the so-called "smaller phi to the n-th power&...


3

APL (Dyalog Unicode), 81 75 bytes ⌊{⌽q⊃⍨⊃⍋|-/¨q←⊃,/2,/¨p/⍨B∊¨p←2(+/⍤↑,⊢,¯2-/⍤↑⊢)⍣{∧/B≤|¯2↑1⌽⍵}¨⍺,¨(-,⊢)⍳B←⍵}⌈ -6 bytes thanks to @Adám Try it online! Explanation This performs a similar algorithm as @notjagan's answer. For each C between -B and B inclusive, it produces the Lucas sequence containing A,C (where A and B are the minimum and maximum of the two ...


0

Javascript, 65 bytes a=>Math.pow((1+Math.sqrt(5))/2,a).toFixed(k(a));k=b=>b?b+k(b-1):0 Getting Phi by calculating (1+Math.sqrt(5))/2. Getting Fib value using the function: k=b=>b?b+k(b-1):0. Try it out


1

GAS x86-64 for Linux (Machine code), 76 68 bytes Loop-free, because I thought it would be a fun idea. GCC 10.1. Note/warning: for this to work, you have to turn off DEP and PIE (ASLR). See compilation instructions below. Look, ma! No loops! Byte count is for the assembled opcodes of func + e + f. Works on 32 bit input. Sure, you'll eventually run out of ...


1

Actually, 16 bytes "1,"◙01W;a+;◙',◙ Try it online!


0

Python 2, 59 51 55 33 bytes a=0 b=1 while 1:a,b=b,a+b;print a Try it online! Thanks for @pppery for saving a whole 22 bytes!


Top 50 recent answers are included