[Question]
  [
Starting with 1, output the sequence of integers which cannot be represented as the sum of powers of earlier terms. Each previous term can be used at most once, and the exponents must be non-negative integers.
This sequence starts:
```
1, 2, 6, 12, 25, 85, 194, 590, 1695, 4879, 19077, 83994, 167988
```
For example, after 1 and 2:
* \$ 3 = 1^1 + 2^1 \$, so 3 is not in the sequence
* \$ 4 = 2^2 \$, so 4 is not in the sequence
* \$ 5 = 1^1 + 2^2 \$, so 5 is not in the sequence
* \$ 6 \$ cannot be represented in this way, so 6 is in the sequence
* etc.
The powers can also be 0; for example, \$ 24 = 1^1+2^4+6^1+12^0 \$, so 24 is not in the sequence.
This is [OEIS A034875](https://oeis.org/A034875).
## Rules
* As with standard [sequence](/questions/tagged/sequence "show questions tagged 'sequence'") challenges, you may choose to either:
	+ Take an input `n` and output the `n`th term of the sequence
	+ Take an input `n`and output the first `n` terms
	+ Output the sequence indefinitely, e.g. using a generator
* You may use 0- or 1-indexing
* You may use any [standard I/O method](https://codegolf.meta.stackexchange.com/q/2447)
* [Standard loopholes](https://codegolf.meta.stackexchange.com/q/1061) are forbidden
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins
  
[Answer]
# [Python 3](https://docs.python.org/3/), ~~121~~ ~~107~~ ~~105~~ ~~102~~ 101 bytes
-3 inspired by Neil's comments, and another -1 thanks to Neil!
Prints the sequence indefinitely. Runs out of memory before finding 25 on TIO.
```
d,*r=0,
while m:=1:
 d+=1
 for v in r:
  w=m
  for p in range(d):m|=w<<v**p
 if~m>>d&1:r+=d,;print(d)
```
[Try it online!](https://tio.run/##HcpBCoMwEEDRfU4xK2ljFg3dSHS8izBaAyYOgyQI4tXTtJu/eHw@j3WP746lFDJa8GVUXv02Q3BonQJq0SpYdoEEPoJUgoyh9mf8tyl@5gc9XbgwD0PSmhX45Q7jSI110iKZnsXHo06lfAE "Python 3.8 (pre-release) – Try It Online")
---
# [Python 3](https://docs.python.org/3/), ~~186~~ ~~178~~ 166 bytes
Fast version, produces all terms on the OEIS page in 2 minutes locally. Assuming this is correct, the next two terms are \$3828253274\$ and \$24694834727\$. Because of the time is spent in arithmetic with large numbers (native code), a naïve C+gmp translation is only ~2 times faster, and [very ungolfy](https://tio.run/##ZVHJbsMgEL3nK6xElaAmld1eKmF6zyX9gDSyHGMcKGC80FaN/Ot1B1vqehmJefOWGcptXZbTtJHGNd2Q1cbdnB9WG14JaatoFxn3nksrh5VAe3yRdogUESyh3vaythWPdGPrSBNPOEuIO@yPNFCGyBBLWtLTHTIYig2lDaXH80RfDbmXyJAU09ez1BUSGTj8gNoAeTZ3ysImMJtgymPmFwsuX/I2v63eHCCGeExF0yEF4VQmqIrjLzUEURZX4/XC6CFeuvQksNqQFVMpkMJBRbOUIn3N3EEdccY4XbR@0fU/@gj8OVo/nOQAXY7xqauK5xlRjAl8cQdxBD0Rx9R1cE@B1lfaP9k1DNPx72JBmH/7hD1hk3GcTCEtwheB0nt4Tx@l0EXdT1sNPzhtH@8@AQ).
```
m=d=1;r=[]
print(1)
while q:=3:
 s=(~m&m+1).bit_length()-1;d+=s;m>>=s
 for v in r:
  w=q;l=1
  while l<=d:q|=w<<l;l*=v
  if q&1<<d:break
 else:r+=d,;print(d)
 m|=q>>d
```
[Try it online!](https://tio.run/##JY7RCsIgGEbvfYr/KmarQHYT6u@LRERD1yR108lGMHp1W3X3weEcvvGV@yE05zGV4lEjEwkvVzImG3LFKFl66wxEjg0nMGH19jtfM3pqbb45Ex65r@iRCV3jJLxSOBHohgQz2ABpU2DBKByy7/qlnETN44qLlE64Pc4bsR3EHZNS8zaZ@5OAcZPhqUZ9EP8nmhLwK0aldCkf "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~24~~ 22 bytes
```
*þṀŻ$ZŒpŒP€Ẏ§‘ḟ$Ṃ;
⁸Ç¡
```
[Try it online!](https://tio.run/##ATUAyv9qZWxsef//KsO@4bmAxbskWsWScMWSUOKCrOG6jsKn4oCY4bifJOG5gjsK4oG4w4fCof//NA "Jelly – Try It Online")
Takes \$n\$ via STDIN and outputs the first \$n\$ terms in reverse order. [+1 byte](https://tio.run/##AToAxf9qZWxsef//KsO@4bmAxbskWsWScMWSUOKCrOG6jsKn4bmA4oCYUuG4n8ay4biiO0AKMcOHwqH///8z) if the output has to be in ascending order.
Incredibly slow, can handle up to \$n = 4\$ on TIO. If \$a\_n\$ is our sequence so far, then, to generate \$a\_{n+1}\$, the code runs in approximately \$O((2a\_n + 2)^n)\$ time.
-2 bytes thanks to [Jonathan Allan](https://codegolf.stackexchange.com/questions/246671/sequence-of-integers-not-the-sum-of-powers-of-earlier-terms#comment552682_246684)
## How it works
```
*þṀŻ$ZŒpŒP€Ẏ§‘ḟ$Ṃ; - Helper link. Given a list L of integers, returns the list with the next term prepended
    $              - To L:
  Ṁ                -   Maximum
   Ż               -   [0, ..., max(L)]
 þ                 - Over each pair (l, i), l ∈ L, i ∈ [0, ..., max(L)]:
*                  -   Raise l to the ith power
     Z             - Transpose
      Œp           - Cartesian product of rows
        ŒP€        - Powerset of each
           Ẏ       - Collapse into a list of lists
            §      - Sums
               $   - To our list of sums:
             ‘     -   Increment
              ḟ    -   Remove elements in the list of sums
                Ṃ  - Minimum
                 ; - Prepend it to L
⁸Ç¡                  - Main link. No arguments.
⁸                    - Set the return value to []
  ¡                  - Read n from STDIN. Starting with [], do n times:
 Ç                   -   Call the helper link, updating the argument with the previous return value each time
```
---
Alternatively, a much faster version at [36 bytes](https://tio.run/##y0rNyan8///hzgaPQ7uNj@7m0jq873B7lM2x9kdNa4If7liiEghkHJ1UcHRSAJDxcFffoeVAxY8aZgQ93DH/2KaHOxZZcz1q3HG4/dDC//8tAA "Jelly – Try It Online") that can do up to \$n = 8\$ on TIO.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 22 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
-rṀṗL‘a*@ɗ⁸§‘ḟ$Ṃ;@
⁸Ç¡
```
A full program that accepts an integer, `n`, from STDIN and prints the Jelly representation of the first `n` terms so STDOUT.
**[Try it online!](https://tio.run/##y0rNyan8/1@36OHOhoc7p/s8apiRqOVwcvqjxh2HlgM5D3fMV3m4s8nagQsocrj90ML//00B "Jelly – Try It Online")** (6 will time out on TIO.)
### How?
```
-rṀṗL‘a*@ɗ⁸§‘ḟ$Ṃ;@ - Link 1, getNext: list KnownTerms
  Ṁ                - maximum of KnownTerms (given an empty list yields 0)
-                  - -1
 r                 - inclusive range -> Exponents (-1 is an indicator to exclude the base)
    L              - length of KnownTerms
   ṗ               - Cartesian power -> all sets of exponents of size NumberOfTerms
         ɗ⁸        - last three links as a dyad - f(Sets, KnownTerms)
     ‘             - increment all Exponents in the Sets
       *@          - KnownTerms exponentiate Sets (vectorises)
      a            - logical AND (vectorises) (i.e. replace with 0 when the exponent was -1)
           §       - sums
              $    - last two links as a monad:
            ‘      -   increment all the found values
             ḟ     -   filter out the found values
               Ṃ   - minimum
                ;@ - concatenate to KnownTerms
⁸Ç¡ - Main Link: no arguments
⁸   - empty list
  ¡ - repeat...
    - ...times: implicitly take an integer from STDIN
 Ç  - ...action: call Link 1 as a monad
    - implicit print
```
[Answer]
# [JavaScript (V8)](https://v8.dev/), 104 bytes
Prints the sequence forever. Not tremendously fast, but fast enough to reach \$19077\$ on TIO.
```
for(a=N=[];;g``||a.push(N)&print(N))g=(q,i=1,n=++N)=>n<0|!a[i]?0:n<2||g(Q=q*a[i]||1,i,n+q-Q)||g(0,i+1,n)
```
[Try it online!](https://tio.run/##FctNCsIwEEDhs7iRxEwldSW2Y28Q6LoUOgjGcRGT9Gc1d4/t7vHB@9JG8ytzXKrtXsr7lxWhw2FsGj9NInSN6/xRTp9j5rDsoT2qBIw1BDTGaXyG1sqJBh47@wjtTcSrHtPlEJEaGIJJVa8Pt8BmH3Upfw "JavaScript (V8) – Try It Online")
### Note
The way this algorithm works, it would be a bit painful to use \$1^k\$ because we'd need some extra testing to avoid an infinite loop. Instead, we don't use it at all and try to reach either \$n\$ or \$n-1\$ with the other integers. This is why the search function \$g\$ starts at index \$i=1\$ in the array \$a[\:]\$.
---
# [JavaScript (V8)](https://v8.dev/), 101 bytes
Slower but a little shorter.
```
for(a=N=[];;g``||a.push(N)&print(N))g=(q,i=1,n=++N)=>n*a[i]>=0&&n<2|g(Q=q*a[i]||1,i,n+q-Q)|g(0,i+1,n)
```
[Try it online!](https://tio.run/##HctBCoMwEEDR24RME0W7Eux4hIBrERwKptNFmkTrau6ehu4@D/6bLjqemePZXEMp@ydrQofLOo5@20Sojd/jpR2omDmcNcCjTpaxtwGNcYBTuNHC64SdUuFxF69nTH8S6S3bYFIzQ@XOsqkXlPID "JavaScript (V8) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 42 bytes
```
Ｎθ≔⁰ηＷ‹Ｌυθ«≦⊕η≔⟦η⟧ζＦυＦ⮌ζＦλ⊞ζ⁻λＸκμ¿Πζ⊞υη»Ｉυ
```
[Try it online!](https://tio.run/##LY69DsIwDIRn@hQebSlILEydEBMSoIoVMZRiSESatPkpUhHPHkLpYstnf3duZO0aW@uUdqaL4RjbKzvsqSw23quHwZUAmaeXVJoB9@x9LuYRJEYS0BPBu1gc6m4@35nGccsm8O0PLubFWV4EjD/hbh1kGKZ@4oGdZxxpFjRBFb3EUcBBmehRC6jsKz/1FNAS/RzUHbBy9habMIETEP95n6JyygTc1j7kFCpTWqfloL8 "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Port of @ovs' Python answer, except outputs the first `n` terms.
```
Ｎθ
```
Input `n`.
```
≔⁰η
```
Start looking for terms.
```
Ｗ‹Ｌυθ«
```
Repeat until enough terms have been found.
```
≦⊕η
```
Try the next integer.
```
≔⟦η⟧ζ
```
Start with a list of just that integer, corresponding to no powers of earlier terms yet.
```
Ｆυ
```
For each earlier term...
```
Ｆ⮌ζ
```
... for each value in a (reversed because it's the golfiest way to) copy of the list...
```
Ｆλ⊞ζ⁻λＸκμ
```
... subtract some powers of the earlier term and add the results to the list.
```
¿Πζ⊞υη
```
If there were no zeros in the list (i.e. the product is nonzero), meaning that no sums of powers added to the current integer, then add it as a term.
```
»Ｉυ
```
Output all of the found terms.
~~76~~ 74 bytes for a somewhat faster version based on @ovs' faster version:
```
Ｎθ≔³ε≔⁰ζ⊞υ¹Ｗ‹Ｌυθ«Ｗ＆εＸ²ζ≦⊕ζ≔³εＦυ«≔εδ≔¹ιＷ∧⊖κ¬›ιζ«≧｜×δＸ²ιε≧×κι»»¿¬＆εＸ²ζ⊞υζ»Ｉυ
```
[Try it online!](https://tio.run/##fZBhS8MwEIY/t7/iPiYQYZ0f92kqyMDNIv6B2N7aY226JakFZb@9XtZmKoIQQl7u8r7PXVFrW3S6GceNOfZ@17dvaMVJrtK1c1QZcasAv9VCwQervHe16BVk/B5qahDEEzrHl6k8V6SCk5TwmSZz9Y78QA7XphSoIO8GDlkGL@7a6uPsvjGFxRaNx3LKSX5DJPvOArsH41hiuzKUos4U0EXPySHyAa@@4sBsu86LR4vaMwVNFJNncmV5oar2EfvZKnilFp0of8CTlDPWn3@XZgWHyHJOw6E9iBD9zzIkxNWG8c9pbsl4ca@d57HlahyzxXjz3nwB "Charcoal – Try It Online") Link is to verbose version of code.
[Answer]
# [Python 3](https://docs.python.org/3/), 179 bytes
```
from itertools import*
def f(n):
	x,N=[1],2
	while len(x)<n:x=[x+[N],x][N in[sum([N**p for N,p in zip(x,e)if-1<p])for e in product(*[list(range(-1,N))for _ in x])]];N+=1
	return x
```
[Try it online!](https://tio.run/##HcpBDsIgEEDRdTkFywHpAo2b2l6BCxBijAVL0gKZ0oheHlu3//30yVMMl1odxoX6bDHHOK/ULyli5mS0jjoIrCNNEWrQ0ogzad6Tny2dbYDC@tCVQZeTVkYUoxX1Qa/bAlpxnqiLSJVIe6Rfn6AIy7xrZZ8MO8gekDCO2zMD17NfM@AjvCy0Uij2f@7HUwwz5qZOgyQN2rzhnmpCHzI4uDJWfw "Python 3 – Try It Online")
It is quite slow, the TIO link will only let you test up to `n=5`
# Explanation
```
from itertools import*
def f(n):
    x,N=[1],2                                                              # Initialise the list, start testing from 2
    while len(x)<n:                                                        # Condition to get the first n terms of the sequence
                   [N in                                                   # Returns False (indexes 0) if N not in list,
        x=[x+[N],                                                          # appending N to the list,
                 x]                                                        # else leave the list unchanged
                        [sum([N**p for N,p in zip(x,e)                     # Sum of the previous sequence terms raised to their respective powers,
                            if-1<p])                                       # unless it's not in this permutation (a power of -1 is used to represent a 0 multiplier)
                                for e in product(                          # Permutations of the possible powers for the previous terms of the sequence
                                    *[list(range(-1,N))for _ in x])]];     # Possible powers for each previous term of the sequence.
                                                                      N+=1 # Increment number
    return x                                                               # Return the sequece
```
The main reason this runs so slow is because there are so many permutations for all the powers, and because list comprehension is used it has to calculate all permutations. Currently all possible powers from `0` to `n-1` are considered, as this was the shortest way to do it in bytes (and still theoretically be able to calculate for any `n`). A faster solution would be to limit the possible powers, for example by replacing `[list(range(-1,N))for _ in x]` with `([[-1,0]]+[[-1]+[i for i in range(int(math.log(N,j))+1)]for j in x[1:]])`, which only lets each term go up to the power such that \$t\_i^p<N\$
[Answer]
# [Ruby](https://www.ruby-lang.org/), 93 bytes
```
*r=p a=1;a+=1while[a]-[0].product(*r.map{|w|[0]+(0..a).map{|e|w**e}}).map(&:sum)==[]||r<<p(a)
```
[Try it online!](https://tio.run/##JcjRCkAwFADQX/GkbbJ4xf2StYeLFUXWZS25vn3E4zkU@jMlReAzhLrFAuo4zYszaEtTWe1pG8NwCEV6RX9x5HcLUWmN8h/HUSl33x9F3uxhlQDGMlPXeYEypQc "Ruby – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 119 bytes
```
while(){map{$o=$_;my$s;map{$s+=$o%$m?$_**($o%$m-1):0;$s-$t||next;$o/=$m}@s}0..($m=2+log(++$t)/.69)**@s;push@s,$t;say$t}
```
[Try it online!](https://tio.run/##HcdZCoMwFAXQzdxChhq1YKF9hLqBrkH8kCoYE/rSQdStNwX/zgndc6wSVltS@vTD2Am5uDYs8BYNuRlMe1lb@APcDY1SYmdWymtB4AxxXafuGwk@t3BbzVthjICzJz36h9AaUebmfJFK1UzhxX3NR0TidkbcUvr5EAc/ccru78qUxR8 "Perl 5 – Try It Online")
Dog slow. *Try it online* found 1, 2, 6, 12, 25, 85, 194 within its 60 second timeout. Same code found 85 within 0.7 seconds on my laptop, 194 within 8 seconds and 590 took 14 minutes.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 28 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
2Lλ∞λ©K.Δ®sÝδm0δšÅ»â}θ€˜Oyå≠
```
Outputs the infinite sequence.
Should have been 27 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage), but a regular reduce-by `.»â}` instead of 'keep last after cumulative reduce-by' `Å»â}θ` doesn't work for some reason.. :/
[Try it online.](https://tio.run/##ATsAxP9vc2FiaWX//zJMzrviiJ7Ou8KpSy7OlMKuc8OdzrRtMM60xaHDhcK7w6J9zrjigqzLnE95w6XiiaD//w)
**Explanation:**
```
  λ            # Start a recursive environment,
               # to generate the infinite sequence
2L             # Starting with a(0)=1 and a(1)=2
               # Where every next a(n) is calculated as:
   ∞           #  Push an infinite positive list [1,2,3,...]
    λ          #  Push a list of all previous terms [a(0),a(1),...,a(n-1)]
     ©         #  Store it in variable `®` (without popping)
      K        #  Remove those values from the infinite list
   .Δ          #  Then find the first value which is truthy for:
     ®         #   Push the list of previous terms `®`
      s        #   Swap so the current value is at the top
       Ý       #   Pop and push a list in the range [0,value]
        δ      #   Apply double-vectorized:
         m     #    Exponentiation
           δ   #   Map over each inner list:
          0 š  #    Prepend a 0
     Å»        #   Cumulative right-reduce by:
       â       #    Cartesian product of both list to create pairs
      }θ       #   After the cumulative right-reduce, leave the final result
        €˜     #   Flatten each inner list
          O    #   Sum each inner list
           yå≠ #   Check that the current value is NOT in this list of sums
               #   (after which the result is output implicitly)
```
]