# To exponential digit growth and beyond!

## Challenge

Given a base $$\1 < b < 10\$$ and an index $$\t \ge 1\$$, output term $$\x_t\$$, defined as follows:

• $$\x_1 = 11_{10}\$$
• $$\x_{i+1}\$$ is obtained by converting $$\x_i\$$ to base $$\b\$$ and then reinterpreting its digits in base $$\10\$$
• Output should be in base $$\10\$$

A walk through for base 5, term 5 would be:

• $$\x_1 = 11_{10}\$$.
• $$\11_{10} = 21_{5}\$$ so $$\x_2 = 21_{10}\$$.
• $$\21_{10} = 41_{5}\$$ so $$\x_3 = 41_{10}\$$.
• $$\41_{10} = 131_{5}\$$ so $$\x_4 = 131_{10}\$$.
• $$\131_{10} = 1011_{5}\$$ so $$\x_5 = 1011_{10}\$$.
• We output the string "1011" or the integer 1011.

## Test Cases

Note: these are one indexed

base 2, term 5 --> 1100100111110011010011100010101000011000101001000100011011011010001111011100010000001000010011100011
base 9, term 70 --> 1202167480887
base 8, term 30 --> 4752456545
base 4, term 13 --> 2123103032103331200023103133211223233322200311320011300320320100312133201303003031113021311200322222332322220300332231220022313031200030333132302313012110123012123010113230200132021023101313232010013102221103203031121232122020233303303303211132313213012222331020133


## Notes

• Standard loopholes are not allowed
• Any default I/O method is allowed
• You may use different indexes (such as 0-indexed, 1-indexed, 2-indexed, etc) for $$\t\$$
• You may output the first $$\t\$$ terms.
• As this is , shortest code wins for that language
• Do we have to support larger numbers or just numbers up to 2^31 - 1? May 19, 2019 at 23:39
• @EmbodimentofIgnorance The maximum of your language (Remember the standard loophole, though!) May 19, 2019 at 23:43
• Is there a challenge that includes bases > 10? (In that case you would repeatedly interpret 11 as if it was in base b and convert it back to base 10, etc.)
– Neil
May 21, 2019 at 11:11
• @Neil I didn't include bases higher than 10 since (for example) 4a wouldn't be a valid number in base-10 May 22, 2019 at 22:49
• You wouldn't get 4a, since you'd be interpreting the base 10 digits as base b and converting to base 10 each time (i.e. the other way around from this question).
– Neil
May 22, 2019 at 22:59

# JavaScript (Node.js), 40 bytes

Thanks to @Neil for saving 5 bytes on this version and 2 bytes on the BigInt version

Takes input as (t)(base), where $$\t\$$ is 1-indexed.

n=>g=(b,x=11)=>--n?g(b,+x.toString(b)):x


Try it online!

# JavaScript (Node.js), 48 bytes (BigInt version)

Takes input as (t)(base), where $$\t\$$ is 1-indexed. Returns a BigInt.

n=>g=(b,x=11n)=>--n?g(b,BigInt(x.toString(b))):x


Try it online!

• Do you need to eval in the first version? + would save 5 bytes...
– Neil
May 20, 2019 at 0:36
• And BigInt saves two bytes in the second version, because you don't need to add n to the string.
– Neil
May 20, 2019 at 0:37
• (b,t,x=11)=>--t?f(b,t,+x.toString(b)):x is 1 char shorter May 25, 2019 at 21:45
• @Qwertiy It's actually 1 byte longer, because we'd need to prepend f= (since the function is referencing itself). May 25, 2019 at 22:04
• @Arnauld, oops. Then this one n=>b=>g=(x=11n)=>--n?g(BigInt(x.toString(b))):x :) If call f(t)(b)() is allowed. May 25, 2019 at 22:07

# 05AB1E, 5 bytes

>IF¹B


Try it online!

Explanation

>       # increment <base>
IF     # <term> times do:
¹B   # convert from base-10 to base-<base>


Note that there is no need to explicitly start the sequence at 11.
Starting at base+1 and doing an extra iteration will result in the first iteration giving 11.

# Japt, 9 bytes

ÆB=sV n
B


Try it

(Two inputs, U and V)
Æ            Range [0..U)
B=          For each, set B (B is preinitialized to 11) to
sV          B's previous value converted to base-V
n           and back to base-10
B            Print out B's final value

• This will never be able to output the first term, will it? May 20, 2019 at 7:14
• @Shaggy Fixed at the cost of two bytes May 20, 2019 at 21:57
• Nicely saved :) Wouldn't have thought of doing that meself. May 21, 2019 at 22:25

# Husk, 7 bytes

!¡odB¹→


Try it online! This version is 2-indexed; it takes the two inputs $$\b\$$ and $$\t\$$ as arguments.

### Explanation

!¡odB²→²⁰  (Written with explicit arguments; let B and T denote them.)
!       ⁰  Take element T of
¡          the function repeatedly applied to
→²     B + 1:
o B²       Convert to base B
od         then convert to decimal.


# Wolfram Language (Mathematica), 46 bytes

bNest[FromDigits[#~IntegerDigits~b]&,11,#]&


Try it online!

Call with f[base][t]. 0-indexed.

• 41 bytes May 20, 2019 at 8:37

# Retina, 67 bytes

.+,(\d+)
11,$1* "$+"{^\d+
*
)+(?=_.*,(_+))(\1)*(_*)
$#2*_$.3
,_+



Try it online! Takes comma-separated inputs $$\t\$$ (0-indexed) and $$\b\$$. Does all of its calculations in unary so times out for large numbers. Explanation:

.+,(\d+)
11,$1*  Initialise $$\x_0=11\$$ and convert $$\b\$$ to unary. "$+"{


Repeat $$\t\$$ times.

^\d+
*


Convert $$\x_i\$$ to unary.

)+(?=_.*,(_+))(\1)*(_*)
$#2*_$.3


Convert to base $$\b\$$.

,_+



Delete $$\b\$$ from the output.

# Python 2, 71 bytes

def f(b,n):h=lambda x:x and x%b+10*h(x/b);return n and h(f(b,n-1))or 11


Try it online!

0-indexed.

# Clojure, 109 bytes

Credit to MilkyWay90 for removing 10 bytes by spotting unnecessary spaces Credit to Embodiment of Ignorance for another byte from another unnecessary space

Golfed

(defn f([b t](f b t 11))([b t v](if(= t 1)v(f b(dec t)(read-string(.(new BigInteger(str v))(toString b)))))))


Ungolfed

(defn f
([base term] (f base term 11))
([base term value] (if (= term 1)
value
(f base (dec term) (read-string (. (new BigInteger (str value)) (toString base)))))))


I think the main place bytes could be saved is the expression for... reradixing? whatever that would be called. Specifically:

(read-string (. (new BigInteger (str value)) (toString base)))

• Do you need those spaces? Can you eliminate spaces? May 20, 2019 at 14:32
• Didn't even occur to me to remove spaces where they were separating syntactically differentiable things; looks like Clojure is a bit more permissive than I thought. Thank you! May 20, 2019 at 17:50
• There is still an unnecessary space in (if (= t 1) May 20, 2019 at 21:59
• Whoop, good catch 👍 May 21, 2019 at 18:51
• 93 bytes May 22, 2019 at 3:01

# Perl 6, 28 bytes

{(11,+*.base($^b)...*)[$^t]}


Try it online!

The index into the sequence is zero-based.

# Jelly, 8 7 bytes

‘       | b + 1
$⁴¡ | Repeat the following t times b³ | Convert to base b Ḍ | Convert back from decimal to integer  • Explanation for those of us who can't recognize atoms at a quick glance? May 19, 2019 at 23:43 # K (ngn/k), 13 bytes {y(10/x\)/11}  Try it online! # Pyth, 8 bytes uijGQTEh  Try it online! # C# (Visual C# Interactive Compiler), 87 bytes n=>m=>{int g=11;for(var s="";m-->0;g=int.Parse(s),s="")for(;g>0;g/=n)s=g%n+s;return g;}  Saved 5 bytes thanks to @KevinCruijssen Try it online! • 87 bytes by changing the do-while into a regular for-loop. May 20, 2019 at 9:52 # brainfuck, 270 bytes ++<<++<,+++<-[----->-<]<,,[<-----[->++++++++++<]++>[-<+>],]<[>>>>>>[<<<[->>+<<]>>>>>]<<[[>+<-]>>[-[<++++++++++>-]>+>]<[<<]>>[-<<+>>>+<]>>[-[<-[>>+>>]>>[+[-<<+>>]>[-<]<[>]>++>>>]<<<<<-]+>[-<+<+>>]<<[->>+<<]>>>]<[-]<[[-<+>]<<]<]<[->>+<<]<-]>>>>[>>]<<[>-[-----<+>]<----.<<]  Try it online! 0-indexed. The number of iterations is assumed to be at most 255. ## Explanation The tape is laid out as follows: num_iterations 0 0 base digit0 0 digit1 0 digit2 ...  Each digit is actually stored as that digit plus 1, with 0 reserved for "no more digits". During the base conversion, the digits currently being worked on are moved one cell to the right, and the base is moved to the left of the current working area. ++<<++ Initialize initial value 11 <,+++<-[----->-<] Get single digit as base and subtract 48 to get actual number <,,[<-----[->++++++++++<]++>[-<+>],] Read multiple digits as number of iterations < Go to cell containing number of iterations [ For each iteration: >>>>>> Go to tens digit cell [<<<[->>+<<]>>>>>] Move base to just before most significant digit << Return to most significant digit [ For each digit in number starting at the left (right on tape): [>+<-] Move digit one cell to right (to tell where current digit is later) >>[-[<++++++++++>-]>+>] Multiply each other digit by 10 and move left <[<<]>> Return to base [-<<+>>>+<] Copy base to just before digit (again) and just before next digit to right (left on tape) >>[ For each digit at least as significant as this digit: -[<-[>>+>>]>>[+[-<<+>>] Compute "digit" divmod base >[-<]<[>]>++ While computing this: add quotient to next digit; initialize digit to "1" (0) first if "0" (null) >>>]<<<<<-] End of divmod routine +>[-<+<+>>] Leave modulo as current digit and restore base <<[->>+<<] Move base to next position >>> ] <[-]< Delete (now useless) copy of base [[-<+>]<<]< Move digits back to original cells ] Repeat entire routine for each digit <[->>+<<] Move base to original position <- Decrement iteration count ] >>>>[>>]<<[>-[-----<+>]<----.<<] Output by adding 47 to each cell containing a digit  # Charcoal, 14 bytes ≔11ζＦＮ≔⍘ＩζＩηζζ  Try it online! Link is to verbose version of code. Takes inputs as $$\t\$$ (0-indexed) and $$\b\$$. Explanation: ≔11ζ  $$\x_0=11\$$. ＦＮ  Loop $$\b\$$ times. ≔⍘ＩζＩηζ  Calculate $$\x_i\$$. ζ  Output $$\x_t\$$. # Pari/GP, 50 bytes (b,n)->x=11;for(i=2,n,x=fromdigits(digits(x,b)));x  Try it online! # C (gcc), 59 bytes f(t,b){t=t?c(f(t-1,b),b):11;}c(n,b){n=n?c(n/b,b)*10+n%b:0;}  Try it online! # Groovy, 45 bytes a,b,c=11->a--?f(a,b,a.toString(c as int,b)):c  Try it online! Port of @Arnauld's answer # PHP, 83 75 bytes function c($b,$t,$v=11){return $t==1?$v:c($b,$t-1,base_convert($v,10,$b));}


Try it online!

This one will only work work with "small" numbers (e.g. not test cases 1 and 4)

# Japt, 10 bytes

0-indexed. Takes t as the first input, b as the second.

_ìV ì}gBìC


Try it

# Gaia, 8 bytes

Bd
11@↑ₓ


Try it online!

Takes 0-based iterations then base.

Bd		| helper function: convert to Base b (implicit) then convert to base 10
| main function:
11		| push 11
@		| push # of iterations
↑ₓ		| do the above function (helper function) that many times as a monad


# Ruby, 39 bytes

Zero-indexed.

->b,n,x=11{n.times{x=x.to_s(b).to_i};x}


Try it online!

# Perl 5-Mbigint -pa, 65 bytes

$\=11;map{$p=$\;$\%=0+"@F";$\=($p%"@F").$\while$p/=0+"@F"}2..<>}{


Try it online!

# GolfScript, 16 bytes

11\~{base""*~}+*


Try it online!

The input is t (0-indexed) and then b.

11                 # x_1
\~               # Parse the inputs to integers
{base""*~}+    # Add b to the beginning of this block to get {b base""*~}
{b base""*~}     # This block goes from x_n to x_(n+1)
b base          # Convert to base b
""*       # Join the digits with "" between them
~      # Parse it to an integer
*   # Execute this block t times