[Question]
  [
### Your task
Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$
### Example
Let's say we are given the inputs \$x=4\$ and \$d=2\$.
First, we get the series \$n^4\$:
* \$0^4 = 0\$
* \$1^4 = 1\$
* \$2^4 = 16\$
* \$3^4 = 81\$
* ...
These are the first 10 elements:
```
0 1 16 81 256 625 1296 2401 4096 6561
```
Now we work out the differences:
```
0 1 16 81 256 625 1296 2401  // Original series
 1 15 65 175 369 671 1105    // 1st difference
  14 50 110 194 302 434      // 2nd difference
```
Finally, we get the 5th term (1-indexed) and output:
```
302
```
Note: this is [sequence](/questions/tagged/sequence "show questions tagged 'sequence'"), so as long as the 5th term is somewhere in your output, it's fine.
### Test cases
```
x  d  OUTPUT
4  2  302
2  1  9
3  2  30
5  3  1830
```
[This Python program](https://tio.run/##Vcs7DoMwEEXRnlVMh40cKQSlQcoqUiIK80nigsEy5pfNOzOWUET73j12958RizDAAwx6YdDOXkgZNA0VQpbBAK/RAdINTuO7F/lV1ol1nKfP3pl@KlMFWiZJw2iHC2zRbAp2Zl9jhaaiysv6T/PJs2vItexWckt0i4L1cA0VZ3fDjl1LrmM3k/PReQXz4Voqzq5w0XUyhPsP) can be used to get the first three differences of any power series.
### Rules
* **This is [sequence](/questions/tagged/sequence "show questions tagged 'sequence'"), so the input/output can be in any form.**
* **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code in bytes wins!**
  
[Answer]
# [R](https://www.r-project.org), ~~26~~ 24 bytes
```
\(x,d)diff((0:5^d)^x,,d)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMH6gvzy1KL44tTC-JTMtDTbpaUlaboWO2I0KnRSNEEiGhoGVqZxKZpxFTpAEYj0zXhUXRoVtiY6KbZGmlwY4kZAcUMs4sY41JsCxY2h1ixYAKEB)
Returns the first `5^d-d+1` elements (which is always ≥5) of `d`-th differences.
Obviously, for `d`>1 this includes a lot of unneccessary differences, but simply returning the first 5 elements is ~~2~~ 1 byte\* longer: `\(x,d)diff((-d:4+d)^x,,d)` ([Attempt it here](https://ato.pxeger.com/run?1=m72waMH6gvzy1KL44tTC-JTMtDTbpaUlaboWO2M0KnRSNEEiGhq6KVYm2imacRU6QCGI_M14VG0aFbYmOim2RppcGOJGQHFDLOLGONSbAsWNodYsWAChAQ)).
\*Thanks to pajonk
[Answer]
# [Python](https://www.python.org), 53 bytes
```
f=lambda x,d,b=4:d and f(x,d-1,b+1)-f(x,d-1,b)or b**x
```
[Attempt This Online!](https://ato.pxeger.com/run?1=PYxNCoMwEEb3OcW3KSQ2Fn_BCvYuCWmoEJOgKdizdOOmvZO3aVDpZob3mHnvr3-Fh7PL8nkGnTZrrTsjBqkEZq647KpWQVgFTSOnOZfnnKV_YG6ETJL5eL7pyAa9hfN3SzPWki3j0GEQnvY2cHOZvOkDZYzAj9HQrca4Y3tlWU8VUABlVpC4cuBKysOQOs7omjLbr38)
Straight-forward recursion.
# [Python](https://www.python.org) + NumPy, 50 bytes using builtin `diff`
```
lambda x,d:diff(r_[4:5+d]**x,d)
from numpy import*
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LYxLCsIwAET3OcVshKRGqa2FWqgXUZFKDQbyI6Zgz-KmIHqn3saUdjMDj5n3_rk-PKwZPqI-f7sgNuWYqUbf2gYv3latFIL662lfFev2kiSRMSK81TCddj2kdtaHZHkehfVQkAbW3Q1NWUUmC7eooRtHpQlcbZ9OyUAZI3A-EiroZOWWzZZhXO2BDMjTjMTaAQeSL4QUMSMr83Re_wE)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~7~~ 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
∞ImIF¥
```
-1 byte thanks to *@TheThonnu*
Outputs the infinite sequence minus the first item. Inputs in the order \$x,d\$.
[Try it online.](https://tio.run/##yy9OTMpM/f//Ucc8z1xPt0NL//834TICAA)
**Explanation:**
```
∞       # Push the infinite sequence of positive integers: [1,2,3,...]
 Im     # Takes each to the power of the first input
   IF   # Loop the second input amount of times:
     ¥  #  Get the deltas/forward-differences of the infinite list
        # (after which the infinite list is output implicitly)
```
Outputting the \$5^{th}\$ term would be 9 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) instead by adding a trailing `}3è` (close the loop and get the 0-based 3rd item).
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 112 bytes
```
j;i;*v;f(x,d){v=calloc(d+9,8);for(i=0;i<d+5;)v[i++]=pow(i,x);for(;d--;)for(j=0;j++<i;)v[j-1]-=v[j];x=abs(v[4]);}
```
[Try it online!](https://tio.run/##bZFhb4IwEIa/@ysuJCZF2gxFE01lX5b9CiULa4srQzCUYTPDXx87BIwua9Kjfd/n2t4h2EGItk255rOaJ8RS6V7qUMRZVggivQ1duzwpSqJDn@ut9FbcrXfa86LwVJyJpra3uWSMu90qRTD1vK3uwJTNIxbiN@I2jN8NqXfLyOVNq/MKjrHOiQuXCeDohEqZ6s3uIgjhsqSwoBBQWDX8EZA9gO68Z@4AZU9KVGpAAh/tDRI@suvAH0BR5KYC8RGXM4xKfKqy5529fV3s7eYF58qhcL8PnCEbawTS3aVzqSym@XxYbsHob1UkZHyFC0@jNLtpHDzvyo@Vj2/vzho6cPUj/mDL0Zb/2gbt/vc96gr1W1f@Jp5KRBLiTCWFqQT23MWp2edYvKWAqqG3FpkwVNHd6UmpFKkHobnGUlVfZY4dmTTtj0iy@GBadm5ZdvwF "C (gcc) – Try It Online")
*This works on my machine with gcc version 13.0.0 but the return fails on TIO.*
# [C (gcc)](https://gcc.gnu.org/), ~~66~~ 60 bytes
```
q;f(x,d){q=x;g(d,4);}g(d,b){d=d--?g(d,b+1)-g(d,b):pow(b,q);}
```
[Try it online!](https://tio.run/##bZHtaoMwFIb/9yoOQiG2CbO1hXWZ24@xq5hl2CQ6WavWOBom3vrcUaO0Y4GcJO/7nHycCJYI0bZnHhNDpVufA8MTIunG5U03HtxaBpKx536xXLlsUB@K/EIO9IxYm2YVnKI0Iy7UM8DWCZXS1bt520MA9YbCmoJPYdvwW0AOALqrgbkClCmUqJRFfA/tHRIesve@Z0GRZ7oC8RGVC4xKfKpy4J3QvK5Ds3vBvnUoXK99x2bHeQmkOyvNpDKY5nE7fQSdfqs8JuMtXLgbpcWkcVgue358@Xj3bi9bgd7f8xtbjrb819ZoD/9xqyvUp6r8TSxKRGLizCWFuQT21MW5DjN8vKGAqqZTiXQQqL3dveljqaqvMsMCzJr2R8THKNEtu7TsePoF "C (gcc) – Try It Online")
*Port of [loopy walt](https://codegolf.stackexchange.com/users/107561/loopy-walt)'s [Python answer](https://codegolf.stackexchange.com/a/253999/9481)*  
*Saved 6 bytes thanks to the man himself [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)!!!*
Inputs \$x\$ and \$d\$.  
Returns the \$5^\text{th}\$ term of the power sequence difference.
[Answer]
# Java, ~~127~~ 90 bytes
```
x->d->g(x,d,4)double g(int x,int d,int k){return d>0?g(x,--d,k+1)-g(x,d,k):Math.pow(k,x);}
```
-37 bytes porting [*@loopyWalt*'s Python answer](https://codegolf.stackexchange.com/a/253999/52210)
Outputs the \$5^{th}\$ term like the test cases, except as double instead of int.
[Try it online.](https://tio.run/##jVA9b4MwEN3zK05MtrCt5qNLaOhSVeqQKWPVwcWGGohBcCSOIn47NRSpdOvy/J7f3T2fc3mRPFfFkJSybeEojb2vAHJ/LTo0pUg7m6CprHidydObRZ3phv2v6KXqPksdx5DCYXA8VjzOiGOK7WikJg8yYiyCYyOqCQt6bzR2jQUVPzyP9ZwrVoRryn@aC7o/SvwSdXUlBXM06geA2k8zCbQo0R@Xyig4@33ICRtjs/cPScfVAFC3SHZsQ6NfuWHrpdz@dR/ZdpL9ysNy/uQuXj8nnG4t6rOoOhS1z8bSksAdgtCFAQPliQqDPQSh1dfpywkVqZB1Xd6IozNRdI7sh28)
**Explanation:**
```
x->d->              // Method with two integer parameters and double return-type
  g(x,d,4)          //  Call the recursive method below with k=4
double g(int x,int d,int k){
                    // Recursive method with three integer parameters and double return
  return d>0?       //  If `d` is not 0:
    g(x,--d,k+1)    //   Do a recursive call with x, d-1, k+1
    -g(x,d,k)       //   Subtract a recursive call with x, d-1, k
   :                //  Else:
    Math.pow(k,x);} //   Calculate `k` to the power `x`
                    //   (which results in a double, hence the double return-type)
```
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 43 bytes
```
f(n,d)=polylog(-n,x)*(1-x)^d%x^(d+=5)\x^d--
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMGCpaUlaboWN7XTNPJ0UjRtC_JzKnPy0zV083QqNLU0DHUrNONSVCviNFK0bU01YyriUnR1oVo8EgsKcio1EhV07RQKijLzSoBMJRBHSSE5MSdHI01HIVFTU0chOtpER8EoFsgw0lEwBNHGUL6pjoJxbKwmxDyYUwA)
Using the polylogarithm \$\operatorname{Li}\_{s}(x) = \sum\_{k=1}^\infty\frac{x^k}{k^s}\$. When \$s=-n\$, this is the generating function of the sequence \$1^n, 2^n, 3^n, \dots\$. Taking the \$d\$th difference is just multiplying the generating function by \$(1-x)^d\$.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 7 bytes
```
Þ∞$e$(¯
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyLigKYiLCIiLCLDnuKIniRlJCjCryIsIiIsIjRcbjIiXQ==)
"Make infinite lists of numbers a digraph" they said. "It doesn't need to be 1 byte" they said. Well look where that got us :p. Could be 6 bytes in 2.4.1 but I don't know if it actually prints.
## Explained
```
Þ∞$e$(¯
Þ∞$e    # [1 ** x, 2 ** x, 3 ** x, ...]
    $(  # d times:
      ¯ #   deltas
```
[Answer]
# Excel (ms365), 143 bytes
```
=INDEX(REDUCE((ROW(1:1048576)-1)^A2,SEQUENCE(B2),LAMBDA(a,b,HSTACK(a,LET(c,TAKE(a,,-1),d,FILTER(c,ISNUMBER(c)),DROP(d,1)-DROP(d,-1))))),5,B2+1)
```
[![enter image description here](https://i.stack.imgur.com/FilTp.png)](https://i.stack.imgur.com/FilTp.png)
* `ROW(1:1048576)-1)^A2` - 1st Parameter in `REDUCE()` to have our 'n' thus 'infinite' (as many rows as possible in Excel) to the power of x;
* `SEQUENCE(B2)` - The 2nd parameter of `REDUCE()` will tell the function to loop d-times;
* `LAMBDA(a,b,HSTACK(a,LET(c,TAKE(a,,-1),d,FILTER(c,ISNUMBER(c)),DROP(d,1)-DROP(d,-1))))` - The lambda helper function will keep pushing new columns with the difference between each value and it's predecessor;
* The above is wrapped into `INDEX()` to grab the 5th element from the latest column.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 9 bytes
```
.+F^Rvz+5
```
[Try it online!](https://tio.run/##K6gsyfj/X0/bLS6orErb9P9/Yy5TAA "Pyth – Try It Online") or [Test suite.](https://pythtemp.herokuapp.com/?code=.%2BF%5ERvz%2B5&test_suite=1&test_suite_input=2%0A4%0A%0A1%0A2%0A%0A2%0A3%0A%0A3%0A5%0A&debug=0&input_size=3 "Pyth – Try It Online")
Input is in the form \$d\$ then \$x\$. Returns the first \$5\$ terms of the sequence.
**Explanation:**
```
.+F^Rvz+5QQ # Whole program. Implicit input Q (as d) added
    R       #  right map with lambda taking one argument:
   ^        #  using exponentiation
      z     #   the second input (x)
     v      #   evaluated
       +5Q  #  into implicit range(5 + d)
  F         # repeat the function
.+          # deltas
          Q #  d times
```
[Answer]
# JavaScript (ES7), 38 bytes
Expects `(x)(d)`. Same recursion as [loopy walt in Python](https://codegolf.stackexchange.com/a/253999/58563).
```
x=>g=(d,k=4)=>d--?g(d,k+1)-g(d,k):k**x
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/C1i7dViNFJ9vWRNPWLkVX1z4dxNM21NQFMzStsrW0Kv4n5@cV5@ek6uXkp2ukaZhoahhpairo6ysYGxhxocoZaWoYQuQs0WSMkXShSZlqAmXBUoYWxgb/AQ "JavaScript (Node.js) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~28~~ 27 bytes
```
ＮθＮη≔Ｅ⁺⁵ηＸιθζＦηＵＭζ⁻κ§ζ⊖λＩ⊟ζ
```
[Try it online!](https://tio.run/##TYuxDoIwFEV3vuKNr0ldjE5MBBcGSH@hQpXG9hXaooafr4/Nu52bc8ZZxzFoV0pHy5aHzd9NxFXU1T/PzE1K9knY6wWV2xJeJcxCggofFqyEVTDtLD5CBC6AzTZ4r2nCXUJviaOXhCZ3NJnv8d3MGI03lM2ETvDqSkVLGVudMqqw4H6cpVyqczm93Q8 "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
ＮθＮη
```
Input `x` and `d`.
```
≔Ｅ⁺⁵ηＸιθζ
```
Generate `d+5` `x`th powers.
```
ＦηＵＭζ⁻κ§ζ⊖λ
```
Generate differences `d` times.
```
Ｉ⊟ζ
```
Output the last difference (which is now the fifth).
[Answer]
# [sclin](https://github.com/molarmanful/sclin), 29 bytes
```
$W rev ^"."itr
2%`",_ - _"map
```
[Try it here!](https://replit.com/@molarmanful/try-sclin) Takes input *n* and returns an infinite list of infinite lists starting from *d* = 0.
For testing purposes:
```
5 ; >kv ( ,_ 10tk >A swap >o ": ">o f>o ) map 10tk >A
$W rev ^"."itr
2%`",_ - _"map
```
## Explanation
Prettified code:
```
$W rev ^ \; itr
2%` ( ,_ - _ ) map
```
Assuming input *d* and *n*.
* `$W` infinite range [0, ∞)
* `rev ^` i.e. `range ^ n`
* `\; itr` successively apply next line to create infinite list
	+ `2%`` sliding pairs
	+ `( ,_ - _ ) map` difference of each pair
[Answer]
# [Desmos](https://www.desmos.com/), ~~44~~ 43 bytes
-1 byte thanks to Aiden Chow
```
f(n,d)=∑_{k=0}^d(-1)^{d-k}nCr(d,k)(k+4)^n
```
[View it on Desmos.](https://www.desmos.com/calculator/higqk4tdcd)
Takes `n` and `d` as the inputs to a function `f`.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 70 bytes
```
->x,d{s=(0..5**d+x).map{_1**x}
d.times{s=s.each_cons(2).map{_2-_1}}
s}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsEiN9ulpSVpuhY33XTtKnRSqottNQz09Ey1tFK0KzT1chMLquMNtbQqarlS9Eoyc1OLgQqK9VITkzPik_PzijWMoGqMdOMNa2u5imuhpikXKLhFm-gYxXKBGEY6hhCGMUzEVMc4FqJ0wQIIDQA)
[Answer]
# [Clojure](https://clojure.org/), 69 bytes
```
#(nth(iterate(fn[x](map -(rest x)x))(for[i(range)](Math/pow i %)))%2)
```
[Try it online!](https://tio.run/##HYzNCsIwEAbveYoPpLB7ELHVx/AJlj0Eu7H1J6lpxLx9LF6Gucxcn@n@ydZotIDQdhTLRHOx7ItRiFKVXn7BnrKtBZUrM4WUZabs481Y6eLLdFjSFzM6Zu56buxoTKu9RSpGhTg5oVcnPY4bh7@fMahTdbTkCCr@YTiDArZiu3D7AQ "Clojure – Try It Online")
Returns the entire (lazy) sequence.
# [Clojure](https://clojure.org/), ~~82~~ 75 bytes
```
#(nth(nth(iterate(fn[x](map -(rest x)x))(for[i(range)](Math/pow i %)))%2)4)
```
[Try it online!](https://tio.run/##HYtBCsIwEEX3OcWAFGYWIqb1GJ5gmEUwExvRpKYp5vaxdPEfb/H@451fW9GOXgOEfsJU52OxanFVMSRugh@3wBmLrhUaNSIMuXDE4tJTSfDu6nxZ8g8iDEQ0WJqok0GfV/0yN/ACbHgCK4YtXHeOh99gFCNicCkJMMBe7v/@Bw "Clojure – Try It Online")
Returns specifically the 5th term of the sequence.
[Answer]
# [J](https://www.jsoftware.com), ~~19~~ 16 bytes
```
2&(-~/\)i.@+&5^]
```
Takes inspiration from [Jelly](https://codegolf.stackexchange.com/a/254014/110888). Accepts `d` as the left arg and `x` as the right arg.
-3 bytes thanks to [Jonah](https://codegolf.stackexchange.com/users/15469/jonah)
[Attempt This Online!](https://ato.pxeger.com/run?1=m70wa8FOJT31NAVbKwV1BR0FAwUrINbVU3AO8nFbWlqSpmuxwUhNQ7dOP0YzU89BW800LhYifNNOkys1OSNfQT1FoUJdx8dNR11XV1cdIqahZKWjrqBrp6Cuo2TlkKavqWanYKRgYm2oYGRtpGBsbaxgCjFlwQIIDQA)
```
2&(-~/\)i.@+&5^]
        i.@+&5^]  NB. dyadic fork
               ]  NB. returns right arg
        i.@+&5    NB. atop, +&5 adds five to left arg, i. creates a range 0..n-1
              ^   NB. raises each item of the range to y
2&(-~/\) ...      NB. dyadic hook
2&(-~/\)          NB. 2 -~/\ y computes the delta of adjacent elements
                  NB. ~ is necessary to flip the args since, for example, 1-16=_15
                  NB. x(n&u)y is a special form of ^:, it is equivalent to
                  NB. n&u^:x y, which applies n&u to y x times
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 27 bytes
```
\!\(\_{i,#2}i^#\)/.i->4&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7P0YxRuP9pCUx8dWZOspGtZlxyjGa@nqZunYmav8DijLzSqKVde3SHByUY9XqgpMT8@qquUwUahSMdLiMgJShDpcxhGcKpIy5av8DAA "Wolfram Language (Mathematica) – Try It Online")
The private-use character `` is [`\[DifferenceDelta]`](https://reference.wolfram.com/language/ref/DifferenceDelta.html).
This character has code point `U+F4A4`, which is different from what the documentation (as of current writing) claims it to be. `U+2206`, the code point in documentation, corresponds to the similar-looking `\[Laplacian]`/`∆` (undocumented).
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~9~~ 7 bytes
*Edit: saved 2 bytes by outputting an infinite list of infinite lists, instead of just the `d+1`-th infinite list*
```
¡Ẋ-m^⁰N
```
[Try it online!](https://tio.run/##yygtzv6v@Kip8dCmR22THjVu@H9o4cNdXbq5cUC23////03@GwEA "Husk – Try It Online")
Returns an infinite list of infinite lists of differences of `x`-th powers.  
The header in the TIO link extracts the `d+1`-th element of this, which is the infinite list of `d`-th differences.
```
    m       # map over
       N    # all integers 1..infinity
     ^⁰     # getting their x-th powers;
 ¡          # now, make an infinite list of infinite lists by repeatedly
  Ẋ-        # taking pairwise differences;
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 6 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
úr▬kÄ│
```
Inputs in the order \$d,x\$. Outputs a list of the first \$10^{d}-d\$ amount of values, which gives a minimum of 9 terms (for \$d=1\$), including the \$5^{th}\$ term.
[Try it online.](https://tio.run/##y00syUjPz0n7///wrqJH09ZkH255NKXpf8F/IwUTLkMFIy4jBWMuYwVTAA)
**Explanation:**
```
ú       # Push 10 to the power the first (implicit) input-integer `d`
 r      # Pop and push a list in the range [0,10ᵈ)
  ▬     # Take each value to the power of the second (implicit) input `x`
   k    # Push the first input `d` again
    Ä   # Loop that many times, using 1 character as inner code-block:
     │  #  Get the forward-differences of the list
        # (after which the entire stack is output implicitly as result)
```
A trailing `4§` (get 0-based 4th item) can be added to only output the \$5^{th}\$ term: [try it online](https://tio.run/##y00syUjPz0n7///wrqJH09ZkH255NKXJ5NDy//@NFEy4DBWMuIwUjLmMFUwB).
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 13 bytes
```
:e…⟪¤*⟫¦@'ọ&e
```
[Try it online!](https://tio.run/##ASIA3f9nYWlh//86ZeKApuKfqsKkKuKfq8KmQCfhu40mZf//NAoy "Gaia – Try It Online")
I finally figured out how to do for loops in Gaia! Outputs approximately (10\*\*x)-d terms (I think)
## Explained
```
:e…⟪¤*⟫¦@'ọ&e
:e…           # Push range(0, x ** 10) to the stack
   ⟪¤*⟫¦      # and raise each item in that range to the power of x
       @'ọ&   # Repeat the string "ọ" d times (ọ is the deltas/forward differences command)
           e  # and execute that as Gaia code
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
+5Ḷ*I⁸¡
```
A dyadic Link that accepts \$d\$ on the left and \$x\$ on the right and yields a list of the first five terms.
**[Try it online!](https://tio.run/##y0rNyan8/1/b9OGObVqejxp3HFr4//9/o/8mAA "Jelly – Try It Online")**
### How?
```
+5Ḷ*I⁸¡ - Link: integer, d; integer, x
+5      - (d) add five -> d+5
  Ḷ     - lowered range -> [0,1,2,...,d+4]
   *    - exponentiate (x) -> [0^x,1^x,2^x,...,(d+4)^x]
      ¡ - repeat...
     ⁸  - ...times: chain's left argument -> d
    I   - ...action: deltas
```
[Answer]
# [Perl 5](https://www.perl.org/), 65 bytes
```
sub f{my($x,$d,$p)=(@_,4);$d?f($x,--$d,$p+1)- f($x,$d,$p):$p**$x}
```
[Try it online!](https://tio.run/##RY1BC4JAEIXv/oohJnRthUqNSpa6B3npViGUuxKVLmqwIf52Gy3o9N73vYHRsnyEXVe9LqCa59tBwzHlqJlwtgkPWITpRvXW8wY/mTEP1P9sjdp10bSdKkrHAjgGHOYc/On8zHukPuOw@oL/274UUqV1OTBrSP3/Sya2mESDw0z8HrJe6PKW12o09hYVABiBhiIVmFJIo@W1lkSSKCtqgdkpH3FAKajCBuzibsMa7H18gHhnR1bbfQA "Perl 5 – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), 54 49 47 bytes
```
[ dup 5 + iota rot v^n [ differences ] repeat ]
```
Returns the first 5 elements of the sequence.
[Try it online!](https://tio.run/##Pc/LCsIwEAXQfb/iuhaKtgo@wK24cSOupEKoUw1tk5hMC1r67TV94OzmcAfuZCJlbbvr5XQ@7iCc06lDKfgFR@@KVEoOOVlFxaBhTX1@jISOBUvH0p88SZEVhfx60crBWGL@GCsVYx8ETQA/DVaI0GKGeBFNEmE5yHba439igrWnHpYbT213w6MyHueQmgWsZtR3Bc8yy8iOjRNYMiQYSZeNTx1KYeD7pnnY/QA "Factor – Try It Online")
```
                        ! 4 2
dup                     ! 4 2 2
5                       ! 4 2 2 5
+                       ! 4 2 7
iota                    ! 4 2 { 0 1 2 3 4 5 6 }
rot                     ! 2 { 0 1 2 3 4 5 6 } 4
v^n                     ! 2 { 0 1 16 81 256 625 1296 }
[ differences ] repeat  ! { 14 50 110 194 302 }
```
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), ~~8~~ 7 bytes (14 nibbles)
```
`..,~^$@!>>$@-
```
Function that returns an infinite list of infinite lists of all differences of the `x`-th powers of all integers:
```
=@`..,~^$@!>>$@-
     ,~             # make a list 1..infinity
    .               # and map over each number
       ^$           # raising it to  
         @          # the arg1-th power;
  `.                # now iteratively apply this function:
          !         # zip together
           >>$      # this list without the first element
              @     # with itself
               -    # by subtraction (so: get differences)
```
To only output the `d`-th differences (as shown in the screenshot below) costs 1 byte (2 nibbles) more:
```
=                       # get the list at index
 @                      # arg2
```
[![enter image description here](https://i.stack.imgur.com/AkEkI.png)](https://i.stack.imgur.com/AkEkI.png)
[Answer]
# [MATLAB](https://www.gnu.org/software/octave/), 45 bytes
```
function f(x,d)
y=diff((0:5*d).^x,d);y(5)
end
```
Uses built-in diff function with the dth difference argument, outputs the fifth index of the resulting array.
[Try it online!](https://tio.run/##y08uSSxL/f8/rTQvuSQzP08hTaNCJ0WTq9I2JTMtTUPDwMpUK0VTLw4kaF2pYarJlZqX8v8/AA "Octave – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 50 bytes
can someone get rid of `iterate`?
```
x!d=iterate(zipWith(-)=<<tail)[n^x|n<-[0..]]!!d!!4
```
[Try it online!](https://tio.run/##LYxBCsIwFET3nmKyS@C31LaCQuMNXLuoVQINNJiGErMo4t3jx7qbN2@Yybye1vucVzFql2w0ycq3W64uTbJQuuuScV714b5@Qlf0VVkOgxCjEG2ejQvQmM1yeUDe5EojWYXiDG8TIis@BW@W6ELCz0fiXsMqtUMP2RJqQlPVjATJeU84bdD83UYHjmyPPx7yFw "Haskell – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 47 bytes
```
r x 0 i=i^x
r x d i=(r x(d-1)(i+1))-(r x(d-1)i)
```
[Try it online!](https://tio.run/##VYu7CoAwEAR7v2LLHCKYGEGL/IoQiOBhfKAW/n08LYR0szPs5M95jDGlAzdqsOPhLl4OwkpAhUqT4lITVf9mSovnFQ5hQwFgP3i9lHQLA0vONbWhvBjor/SU6eY/5L6V8nrdSUkP "Haskell – Try It Online")
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 89 bytes
Prints **d\*2** junk number in the beginning and another **2** junk numbers at the end.
```
:&5*>:0(?v:1-$:{:}\nao92*0.
:2(?v1-}$ :@*{    >
v~@~\02. >&:1-&1(?vl
>:2(    ?^1-@$:@$-}$
```
[Try it online](https://tio.run/##S8sszvj/30rNVMvOykDDvszKUFfFqtqqNiYvMd/SSMtAj8vKCChsqFuromDloFWtAAR2XGV1DnUxBkZ6CnZqQA1qhkAVOVx2QJUgafs4Q10HFSsHFaCe////65aZArExAA)
# [><>](https://esolangs.org/wiki/Fish), 94 bytes
Only prints numbers in the sequence.
```
:&5*>:0(?v:1-$:{:}c2.
 ~@~/01. >~{~v
:2(?^1-}$:@*{
  vlv?(1&-1:&<~~<
2:<$   }-$@:$@-1^?(
 oan<
```
[Try it online](https://tio.run/##DcMxCsMwDADAXa/QYIwJKI1MswgT@yWBECgtlHYoaDHW15Ue3OP1e7pLXKdNllRVmIJ0GWeeAa3ZbeEZN@umIDnVnWkEaVMHRH1rTRyJJRazAllKQMRBoUloxHtNgN/jU9yddP2/Xw)
[Answer]
# [Scala](https://www.scala-lang.org/), 198 bytes
Golfed version. [Try it online!](https://tio.run/##bY9BS8NAEIXv@RVz3KXJYlp7aRtBkYJgLxZPpZRtsklGNrtxd1orIb89bnpQUC/DzPfeG3g@l1oO2LTWEfjxELnVWuWE1ojmRPKolXhGTw@nslQuiuzxLaiwkWigGwpVwppdFk@G4mKcPOvOUoPPfjK7R3sKX/aML0vrGK6SGyDLNpJq0doPNo8LPrlwQXbMd36SfUsYX3h/TR1WSRpSUASDQFNgrrwonG1fsKqJpVwEl5J53WF25xnyLIxJypNx75deONXYs2JeaGUqqpP0Sslu1Xs/RABjkyaUYtJVfgH3zsnP3ZYcmmrPF/BqkCCDLjgB2kBJG7ZmtzFMOf8FpzGkf@DsP@c8htkV9lE/fAE)
```
def F(x:Int,d:Int)={val s=ListBuffer[Double]();for(i<-0 to(Math.pow(5,d)+x).toInt){s+=Math.pow(i,x)};for(_<-1 to d){s.indices.dropRight(1).foreach{i=>s(i)=s(i+1)-s(i)};s.remove(s.length-1)};s.toSeq}
```
Ungolfed version. [Try it online!](https://tio.run/##bZBRS8MwFIXf@yvOY8K6YDd9GU5QZCC4F8WnMSRr0zbSJiXJ5mTst9fbUrcxfAr33O@ee3N8KivZtrpurAvwXSVSW1UqDdoaUW@D3FRKvGofnrZ5rlwU2c0XdbGU2uAQAZnKsWD7GV5MiJH1L5@hG1k92y2NrzHvSWAnK3iqzn5/COM9kFsHpnE/xg2CBVvKUIrGfrM7suYYYc9FsN2GwRHkN5rjxOmYkL5zPBt@doZJZ5hdzAltMp0qLzJnmzddlIElXNCAkmmJAzTmDwNLNNOcDqeHjkg4xr0ytI8nS6dqu1PMi0qZIpSEJZfXeDq@@3vUCUN2NQXJpCv8DI/OyZ/Ve3DaFGvK8MPocMquITVUhi3YbYwJ51fiJKZV1@L0P5KinPbiMTpGbfsL)
```
import scala.collection.mutable.ListBuffer
object Main {
  def F(x: Int, d: Int): List[Double] = {
    val s = ListBuffer[Double]()
    for (i <- 0 to (Math.pow(5, d) + x).toInt) {
      s += Math.pow(i, x)
    }
    for (_ <- 1 to d) {
      s.indices.dropRight(1).foreach { i =>
        s(i) = s(i + 1) - s(i)
      }
      s.remove(s.length - 1)
    }
    s.toList
  }
  def main(args: Array[String]): Unit = {
    println(F(4, 2))
    println(F(2, 1))
    println(F(3, 2))
    println(F(5, 3))
  }
}
```
]