Fibonacci Exponents

Python, 49 bytes

A recursive lambda which takes a and b as separate arguments (you can also set the first two numbers of fibonacci, x and y, to whatever you want - not intentional, but a nice feature):

f=lambda a,b,x=1,y=1:a<=b and a**x+f(a+1,b,y,x+y)

Try it online! (includes test suite)

Golfing suggestions welcome.


Mathematica, 38 bytes 37 bytes 31 bytes

Sum[x^Fibonacci[x-#+1],{x,##}]&

This is just rahnema1's answer ported to Mathematica. Below is my original solution:

Tr[Range@##^Fibonacci@Range[#2-#+1]]&

Explanation:

## represents the sequence of all the arguments, # represents the first argument, #2 represents the second argument. When called with two arguments a and b, Range[##] will give the list {a, a+1, ..., b} and Range[#2-#+1] will give the list of the same length {1, 2, ..., b-a+1}. Since Fibonacci is Listable, Fibonacci@Range[#2-#+1] will give list of the first b-a+1 Fibonacci numbers. Since Power is Listable, calling it on two lists of equal length will thread it over the lists. Then Tr takes the sum.

Edit: Saved 1 byte thanks to Martin Ender.


Perl 6, 32 30 bytes

{sum $^a..$^b Z**(1,&[+]...*)}

$^a and $^b are the two arguments to the function; $^a..$^b is the range of numbers from $^a to $^b, which is zipped with exponentiation by Z** with the Fibonacci sequence, 1, &[+] ... *.

Thanks to Brad Gilbert for shaving off two bytes.