π) is a transcendental number, and therefore it has a non-terminating decimal representation. Similar, the representation doesn't terminate if written in any other integer base. But what if we wrote it in base
Digits in decimal represent powers of 10, so:
π = 3.14… = (3 * 10^0) + (1 * 10^-1) + (4 * 10^-2) + …
So in base
π, the digits would represent powers of
π = 10 = (1 * π^1) + (0 * π^0)
In this new base, integers now have non-terminating representations. So 10 in decimal now becomes the following:
10 => 100.01022… = (1 * π^2) + (0 * π^1) + (0 * π^0) + (0 * π^-1) + (1 * π^-2) + …
Note that in base
π the digits used are 0,1,2,3 because these are the digits less than
Given a non-negative integer
Output (without halting) its representation in base
π. If the number has a finite representation (0, 1, 2, 3), then the program may halt instead of printing infinite zeros.
Take an arbitrarily large integer
n, and output the first
- Since a number has multiple possible representations, you must output the one that appears the largest (normalized). Just as
1.0 = 0.9999…in decimal, this problem exists in this base, too. In base
π, one is still
1.0, but could also be written as
0.3011…, for example. Similarly, ten is
100.01022…, but could also be written as
- This is code-golf, so fewest bytes wins. Program or function.
- No built-ins (I'm looking at you, Mathematica)
0 = 0 1 = 1 2 = 2 3 = 3 4 = 10.220122021121110301000010110010010230011111021101… 5 = 11.220122021121110301000010110010010230011111021101… 6 = 12.220122021121110301000010110010010230011111021101… 7 = 20.202112002100000030020121222100030110023011000212… 8 = 21.202112002100000030020121222100030110023011000212… 9 = 22.202112002100000030020121222100030110023011000212… 10 = 100.01022122221121122001111210201201022120211001112… 42 = 1101.0102020121020101001210220211111200202102010100… 1337 = 1102021.0222210102022212121030030010230102200221212… 9999 = 100120030.02001010222211020202010210021200221221010…
You can verify any output you want using the Mathematica code here. The first parameter is
x, the third is
n. If it times out, pick a small
n and run it. Then click "Open in Code" to open a new Mathematica worksheet with the program. There's no time limit there.
Convert the resulting output to a number here.