[Question]
  [
I like to think of a 10-adic number as a number that goes infinitely to the left, or an integer modulo a very very large power of 10.
Things carry infinitely to the left and vanish. To see what I mean, note that `...6667 * 3 = 1` in the 10-adic land, since the "2" that carries to the left goes to infinity.
Addition and multiplication make sense for 10-adic numbers, since the last `n` digits of the sum/product only depend on the last `n` digits of the summands/multiplicands.
---
Given `n`, you need to print the last `n` digits of the 10-adic cube root of 3, i.e. `x` satisfiying `x*x*x = 3`.
It ends:
```
...878683312291648481630318492665160423850087895134587
```
---
**Your code must terminate for `n=1000` before submission.**
Let's say that if the number you need to print begins with zero, then you don't need to print the leading zeroes, since it isn't actually the point to print extra zeroes.
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest answer in bytes wins.
  
[Answer]
# [Python 2](https://docs.python.org/2/), 33 bytes
```
lambda k:pow(3,10**k*2/3+1,10**k)
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHbqiC/XMNYx9BASytby0jfWNsQwtb8n21raGBgwFVQlJlXopCmka0JYUIFQNpAgjrGMPUA "Python 2 – Try It Online")
The `pow` function efficiently computes the modular exponent `3**(10**k*2/3+1)%10**k`.
We're asked to find a solution to `r**3 = 3 (mod 10**k)`. We want to find an exponent `e` for which the map `x -> x**e` is inverse to cubing `x -> x**3` working mod `10**k`, just as the decryption and encryption exponents in RSA cancel to produce the original value. This means that `(x**3)**e = x (mod 10**k)` for all `x`. (We'll assume throughout that `gcd(x,10) = 1`.) Then, we can recover `r` by inverting the cubing to get `r = 3**e (mod 10**k)`. 
Expanding out `(r**3)**e = r (mod 10**k)`, we get 
```
r**(3*e-1) = 1 (mod 10**k)
```
We're looking for an exponent `3*e-1` that guarantees that multiplying that many copies gives us `1`.
Multiplication modulo `10**k` forms a group for invertible numbers, that is those with `gcd(x,10) = 1`. By Lagrange's Theorem, `x**c = 1` where `c` is the count of elements in the group. For the group modulo `N`, that count is the Euler totient value `φ(N)`, the number of values from `1` to `N` that are relatively prime to `N`. So, we have `r**φ(10**k) = 1 (mod 10**k)`. Therefore, its suffices for `3*e-1` to be a multiple of `φ(10**k)`.
We compute
```
φ(10**k) = φ(5**k) φ(2**k)= 4 * 5**(k-1) * 2**(k-1) = 4 * 10**(k-1)`
```
So, we want `3*e-1` to be a multiple of `4 * 10**(k-1)`
```
3*e - 1 = r * 4 * 10**(k-1)
e = (4r * 10**(k-1) + 1)/3
```
Many choices are possible for `r`, but `r=5` gives the short expression
```
e = (2 * 10**k + 1)/3
```
with `e` a whole number. A little golfing using floor-division shortens `e` to `10**k*2/3+1`, and expressing `r = 3**e (mod 10**k)` gives the desired result `r`.
[Answer]
# [Python 2 (PyPy)](http://pypy.org/), ~~55~~ 50 bytes
-5 bytes thanks to [@H.P. Wiz](https://codegolf.stackexchange.com/users/71256/h-pwiz)!
```
n=p=1;exec"p*=10;n+=3*(3-n**3)%p;"*input();print n
```
[Try it online!](https://tio.run/##BcHRCoAgDAXQXwkh0IUw83Hsa0LQl3UJg/z6dQ7W7LedGQvL3RRapH3tCiAtLHZopVizEdW0QwINwztjEjzD5mbuhZl/ "Python 2 (PyPy) – Try It Online")
Calculates (non-bruteforcing) digit by digit, so it's faster than brute force.
[Version without exec](https://tio.run/##BcE7CsAgEAXA3lNsE9AVYY2kCeQwKfKxeS5iQE9vZnS0t2ANOnTMiSOau1TqlEH1xHPZDP2adT66Hf5IbFMAc3JLFOZutGY0wpybiPw)
### Explanation
(Thanks [@Leaky Nun](https://codegolf.stackexchange.com/users/48934/leaky-nun) and [@user202729](https://codegolf.stackexchange.com/users/69850/user202729) for figuring this out)
First, observe that \$n^3\$ is an involution modulo 10 (i.e. if the function is called \$f\$, then \$f(f(n)) = n\$). This can be confirmed using an exhaustive search.
We can use mathematical induction to find the next digit.  
Let \$d\_n\$ be the \$n\$th digit of the number (from the right).
$$
\begin{align\*}
d\_1^3 &\equiv 3 &&\pmod{10} \\
d\_1 &\equiv 3^3 &&\pmod{10} \\
 &\equiv 27 &&\pmod{10} \\
 &\equiv 7 &&\pmod{10} \\
\end{align\*}
$$
Now, assume we know the number up to the \$k\$th digit, \$x\$
$$
\begin{align\*}
x^3 &\equiv 3 &&\pmod{10} \\
(d\_{k+1} \cdot 10^k + x)^3 &\equiv 3 &&\pmod{10} \\
m \cdot 10^{2k} + 3 \cdot d\_{k+1} x^2 \cdot 10^k + x^3 &\equiv 3 &&\pmod{10^{k+1}} \;\textrm{(for some } m \textrm{)} \\
3 \cdot d\_{k+1} x^2 \cdot 10^k + x^3 &\equiv 3 &&\pmod{10^{k+1}} \\
\end{align\*}
$$
We know that:
$$
\begin{align\*}
 x &\equiv 7 &&\pmod{10} \\
 x^2 &\equiv 49 &&\pmod{10} \\
 &\equiv 9 &&\pmod{10} \\
 x^2 \cdot 10^k &\equiv 9 \cdot 10^k &&\pmod{10^{k+1}} \\
3 \cdot x^2 \cdot 10^k &\equiv 27 \cdot 10^k &&\pmod{10^{k+1}} \\
 &\equiv 7 \cdot 10^k &&\pmod{10^{k+1}} \\
\end{align\*}
$$
Substituting this in:
$$
\begin{align\*}
3 \cdot d\_{k+1} x^2 \cdot 10^k + x^3 &\equiv 3 &&\pmod{10^{k+1}} \\
7 \cdot d\_{k+1} \cdot 10k + x^3 &\equiv 3 &&\pmod{10^{k+1}} \\
d\_{k+1} &\equiv \frac{3 - x3}{7 \cdot 10^k} &&\pmod{10} \\
\therefore d\_{k+1} &\equiv \frac{3 \cdot \left(3 - x^3\right)}{10^k} &&\pmod{10} \; (7^{-1} \equiv 3 \pmod{10})
\end{align\*}
$$
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 21 bytes
```
PowerMod[3,1/3,10^#]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/A/IL88tcg3PyXaWMdQH4gN4pRj1f4HFGXmlUSnRRsaGBjExv4HAA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~17~~ 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
7IGD3mN°÷7*θì
```
Port of [*@ASCII-only*'s Python 2 (PyPy) answer](https://codegolf.stackexchange.com/a/166418/52210).  
-4 bytes AND bug-fixed for outputs with leading zeros thanks to *@Emigna*, by replacing `T%N°*+` with `θì`.
[Try it online.](https://tio.run/##MzBNTDJM/f/f3NPdxTjX79CGw9vNtc7tOLzm/39Lc3MA)
**Explanation:**
```
7               # Start result-string `r` at '7'
IG              # Loop `N` in the range [1, input)
  D3m           #  `r` to the power 3
       ÷        #  Integer-divided with
     N°         #  10 to the power `N`
        7*      #  Multiplied by 7
          θì    #  Then take the last digit of this, and prepend it to the result `r`
                # Implicitly output result `r` after the loop
```
[Answer]
# Java 8, ~~158~~ ~~156~~ ~~141~~ ~~136~~ 135 bytes
```
n->{var t=n.valueOf(3);var r=n.ONE;for(int i=0;i++<n.intValue();)r=r.add(t.subtract(r.pow(3)).multiply(t).mod(n.TEN.pow(i)));return r;}
```
Port of [*@ASCII-only*'s Python 2 (PyPy) answer](https://codegolf.stackexchange.com/a/166418/52210).  
-2 bytes thanks to *@Neil*.  
-20 bytes thanks to *@ASCII-only*.
NOTE: There is already a [much shorter Java answer by *@OlivierGrégoire*](https://codegolf.stackexchange.com/a/166422/52210) using an algorithmic approach utilizing `modPow`.
[Try it online.](https://tio.run/##pVCxTsMwEN3zFTfaqmoFMZowIHVgIB2KWBDDNXFTB8eJLpegqsq3h0sBiaETLJbvvXvP77nGEdd1@T4XAfsentDHcwLgIzs6YOEgX0aAWvZMg3w0D756FLZyBIW6CkdtRTMlcvSM7AvIIUIGc1zfn0ck4CyaEcPgtgd1q@0CkUDbfGMPLSl5HHyWWr9a3UUj08uyq7TVlJHBslRs@mHPhAUrMl37IS7aNENg34WTYrm3pYrmeZNfWK@1tuR4oAhkp9ku0bphHyTad8Kx9SU00l7tmHysXt8A9Vf13aln15h2YNMJxSGK9fXqv1rpyyf8TX2T/lOe/hhMyTR/Ag)
**Explanation:**
```
n->{                            // Method with BigInteger as both parameter and return-type
  var t=n.valueOf(3);           //  Temp BigInteger with value 3
  var r=n.ONE;                  //  Result-BigInteger, starting at 1
  for(int i=0;i++<n.intValue();)//  Loop `i` in the range [1, n]
    r=r.add(                    //   Add to the result-BigDecimal:
       t.subtract(r.pow(3))     //    `t` subtracted with `r` to the power 3
       .multiply(t)             //    Multiplied by 3
       .mod(n.TEN.pow(i)));     //    Modulo by 10 to the power `i`
  return r;}                    //  Return the result-BigInteger
```
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), 106 bytes
```
n->n.valueOf(3).modPow(n.valueOf(2).multiply(n=n.TEN.pow(n.intValue())).divide(n.valueOf(3)).add(n.ONE),n)
```
[Try it online!](https://tio.run/##bY@xTsNADIb3PIXHO9RaAcbSDkhFYqBFKmJBDEcuCQ4X3ynxBVWozx4uEQKGTpY///psN2Ywy8Z@jNQG3wk0qcco5LCKXAh5xotVVjjT9/BgiOErAwjxzVEBvRhJZfBkoU0zdZCOuH55BdPVvZ6jAHc/nptZ3Rp5x1uq71nKuuwW5@AGKljDyMsN42BcLPeVutbYevvoP9Ufu0osOqHgjorXjE/bHYY5QSzPU0hprdHSQLZU/10ajbWJ7HdbvWA9ruZLD8deyhZ9FAzpEXGsKjRh0p8789d3med5WjRJTtlp/AY "Java (JDK 10) – Try It Online")
## Credits
* Port of [xnor's Python 2 answer](https://codegolf.stackexchange.com/a/166446/16236).
* -6 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)
[Answer]
# [Haskell](https://www.haskell.org/), 37 bytes
1 byte saved thanks to ASCII-only!
```
(10!1!!)
n!x=x:(n*10)!mod(9-3*x^3+x)n
```
[Try it online!](https://tio.run/##y0gszk7NyfmfZhvzX8PQQNFQUVGTK0@xwrbCSiNPy9BAUzE3P0XDUtdYqyLOWLtCM@9/bmJmnm1BUWZeiUqagqGBgcH/f8lpOYnpxf91kwsKAA "Haskell – Try It Online")
I use a similar approach to ASCII-only, but I avoid using division
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), 15
```
3?Ar^d2*3/1+r|p
```
Uses modular exponentiation, like [@xnor's answer](https://codegolf.stackexchange.com/a/166446/11259).
[Try it online!](https://tio.run/##S0n@/9/Y3rEoLsVIy1jfULuopuD/f1NDAA "dc – Try It Online")
TIO calculates input=1000 in 21s.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 12
```
.^3h/y^TQ3^T
```
[Try it online!](https://tio.run/##K6gsyfj/Xy/OOEO/Mi4k0Dgu5P9/U0MA "Pyth – Try It Online")
Again, using modular exponentiation, like [@xnor's answer](https://codegolf.stackexchange.com/a/166446/11259).
[Answer]
# [Pyth](https://pyth.readthedocs.io), 23 bytes
Of course, this uses ASCII-only's approach.
```
K7em=+K*%*7/^K3J^TdTJtU
```
[Try it here!](https://pyth.herokuapp.com/?code=K7em%3D%2BK%2a%25%2a7%2F%5EK3J%5ETdTJtU&input=1000&debug=0)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~26~~ 22 bytes
```
≔⁷ηＦＮ≧⁺﹪×³⁻³Ｘη³Ｘχ⊕ιηＩη
```
[Try it online!](https://tio.run/##NY3NCsIwEITvPkWOuxBBycFDT@Kph0oQXyCmsVlINyU/@vixVrzNx3zDWG@SjSa0ds6ZJoaTFB673TMmAT0vtVzr/HAJEMVglp90o8kX0KFmKYY41hDhTrPLoFYmrlvQ8b3OvBQKEf94PEjRs01udlzcCLR130OdiAtcTC7gEbvWVNu/wgc "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔⁷η
```
Initialise the result to 7. (Doesn't have to be 7, but 0 doesn't work.)
```
ＦＮ
```
Loop over the number of required digits.
```
        η       Current result.
       Ｘ ³     Take the cube. 
     ⁻³         Subtract from 3.
   ×³           Multiply by 3.
            ⊕ι  Increment the loop index.
          Ｘχ    Get that power of 10.
  ﹪             Modulo
≧⁺            η Add to the result.
```
Now uses @H.P.Wiz's approach to save 4 bytes.
```
Ｉη
```
Print the result.
Here's a 28-byte brute-force version that takes cube roots of arbitrary values:
```
ＦＮ⊞υ⊟Φχ¬﹪⁻ＸＩ⁺κ⭆⮌υμ³ＩηＸχ⊕ι↓Ｉυ
```
[Try it online!](https://tio.run/##LUxLCsIwEN33FFlOIILSnS4VoYuWoCeINdpgminJTHv8mFYH3sD79oOJPRqf8wujgCZMTB2PDxtBSqE5DcBKaJzg6jwV9bBXokOCFp/sEVoXOIHGpVhnkwi0L/yjxJ2iC@/WTHCzs43JAkslRinLrwu28LCyX3ndbUIf7WgD2Sc4ud2p0mWH4HjBJfxbXOSc66rOu9l/AQ "Charcoal – Try It Online") Link is to verbose version of code. First input is number of digits, second is value to root.
[Answer]
# [J](http://jsoftware.com/), 33 bytes
```
f=:3 :'((10x^y)|]+3*3-^&3)^:y 1x'
```
[TIO](https://tio.run/##y/r/P83WyljBSl1Dw9CgIq5SsyZW21jLWDdOzVgzzqpSwbBCHahEwdDAwAAA "J – TIO")
port of @ASCII-only's [answer](https://codegolf.stackexchange.com/a/166418/80062) but using fixed modulo 10^n throughout
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~23~~ ~~18~~ 17 bytes
```
*3:×7DṪ×+⁸
R⁵*çƒ7
```
[Try it online!](https://tio.run/##AScA2P9qZWxsef//KjM6w5c3ROG5qsOXK@KBuApS4oG1KsOnxpI3////MTA "Jelly – Try It Online")
I know `ƒ` will be useful.
]