Quantcast
Channel: Length of Binary as Base 10 [OEIS A242347] - Code Golf Stack Exchange
Browsing all 30 articles
Browse latest View live

Answer by Kip the Malamute for Length of Binary as Base 10 [OEIS A242347]

Pyt, 8 bytes2`ĐąŁƥɓłTry it online!Prints indefinitely.2 push 2 ` ł do... while top of stack is truthyĐĐuplicateą convert to ąrray of digitsŁƥƥrint Łengthɓ convert to ɓinary string (implicitly treats...

View Article



Answer by naffetS for Length of Binary as Base 10 [OEIS A242347]

J, 18 bytes[:#@":10x&(#.#:)&2Attempt This Online!-2 thanks to Jonah!

View Article

Answer by Emigna for Length of Binary as Base 10 [OEIS A242347]

><>, 40 bytes2:2(?v:2%$2,:1%-!?v00.>lnao>l1).>a*+a1Try it online"Infinte sequence". Overflows at the 7th number.

View Article

Answer by Kjetil S for Length of Binary as Base 10 [OEIS A242347]

Perl 5 -Mbigint, 58 byteseval'$_=2;'.'$_=new Math::BigInt($_)->to_bin;'x$_;$_=y///cTry it online!

View Article

Answer by Cliff for Length of Binary as Base 10 [OEIS A242347]

Gaia, 11 bytes)2¤U⟪¤bd⟫⊢lTry it online! or Try a test suite!A sort of copy of the Jelly answer but in Gaia. Times out for >= 12 I think.Explained)2¤U⟪¤bd⟫⊢l) # Increment the input 2¤ # Push 2...

View Article


Answer by Kevin Cruijssen for Length of Binary as Base 10 [OEIS A242347]

MathGolf, 7 bytes2æhpià∟Prints the infinite sequence, starting from 1.Try it online.Outputting the first \$n\$ terms would be 8 bytes instead:2kæhpià;Try it online.Explanation:2 # Push a 2∟ # Do-while...

View Article

Answer by Sean for Length of Binary as Base 10 [OEIS A242347]

Raku, 16 30 bytesmap *.chars,(2,+*.base(2)...*)Try it online!An expression for the lazy, infinite sequence of numbers.

View Article

Answer by Kevin Cruijssen for Length of Binary as Base 10 [OEIS A242347]

05AB1E, 6 bytesInfinite sequence starting at 2:Tλb}€gTry it online.Could be the infinite sequence starting at 1 by replacing T with 2: 2λb}€g - try it online.Outputting the \$n^{th}\$ term is 6 bytes...

View Article


Answer by Hugo Pfoertner for Length of Binary as Base 10 [OEIS A242347]

PARI/GP 55 bytesf(n)=k=2;d=digits;while(n--,k=fromdigits(d(k,2)));#d(k)Stack of 8 GBytes overflows for n=18.

View Article


Answer by The Thonnu for Length of Binary as Base 10 [OEIS A242347]

Sequences, \$9 \log_{256}(96)\approx\$ 7.4 bytes2HE2hBnHzExplanation2HE2hBnHz E // Infinite sequence2H // Starting with 2 // For each term: 2hB // Convert to binary n // Interpret as integer H // And...

View Article

Answer by Stephen for Length of Binary as Base 10 [OEIS A242347]

cQuents, 9 bytesLb$=2:JZTry it online!Prints the entirely sequence infinitely starting with 1,2,4,10,31,100,330,...ExplanationFirst line implicit : output the nth term if input is provided, or all...

View Article

Answer by naffetS for Length of Binary as Base 10 [OEIS A242347]

APL (dzaima/APL), 19 bytes{≢⍕(10⊥2∘⊥⍣¯1)⍣⍵⊢2}Try it online!Due to limits, this can also only output the first 5 elements.This works in Dyalog too, but can only output the first 3 elements there.

View Article

Answer by naffetS for Length of Binary as Base 10 [OEIS A242347]

K (ngn/k), 14 bytes{#$x(10/2\)/2}Try it online!Outputs the nth element.Unfortunately, this can only do the first 3 elements because it's written in C, so overflow happens very quickly.

View Article


Answer by Aiden Chow for Length of Binary as Base 10 [OEIS A242347]

Pip, 10 bytesY2LaP#TB:yTry It Online!Prints the first a terms in the sequence starting with 2, where a is the argument input.Y2LaP#TB:y ; a = inputY2 ; Set y = 2 La ; Loop the following code "a"...

View Article

Answer by Neil for Length of Binary as Base 10 [OEIS A242347]

Retina 0.8.2, 45 bytes.+$*:2{`:\d+$*B+`(B+)\1$1AABB}T`L`d.Try it online! Outputs the 0-indexed nth term. Link includes test cases for 0 to 3 as higher values are too slow. Explanation:.+$*:2Convert the...

View Article


Answer by Neil for Length of Binary as Base 10 [OEIS A242347]

Charcoal, 17 bytes≔2θFN«⟦ILθ⟧≔⍘Iθ²θTry it online! Link is to verbose version of code. As we are outputting A242347, which starts with 1, so does this version. Explanation:≔2θStart with 2.FN«Repeat n...

View Article

Image may be NSFW.
Clik here to view.

Answer by chunes for Length of Binary as Base 10 [OEIS A242347]

Factor, 35 bytes2 [ >bin dup length . dec> t ] loopPrints the infinite sequence starting with 2. Times out on TIO, but here's a screenshot using the debugger to step through some of the starting...

View Article


Answer by hakr14 for Length of Binary as Base 10 [OEIS A242347]

Pyth, 10 bytesL.BsbmlyF2Test suitePrints the first \$n\$ terms.The m can be omitted to instead print \$a(n)\$, where \$a(0)=2\$.

View Article

Answer by Mama Fun Roll for Length of Binary as Base 10 [OEIS A242347]

sclin, 21 bytes"2""2X>b >S"itr"len"mapTry it here! Returns an infinite list.For testing purposes (use -i flag if running locally):; 10tk >A"2""2X>b >S"itr"len"mapExplanationPrettified...

View Article

Answer by AZTECCO for Length of Binary as Base 10 [OEIS A242347]

Haskell, 75 63 bytesg 2g x=length(show$f x):g(f x)f 0=0f n=f(div n 2)*10+mod n 2Try it online!Thanks to @Sʨɠɠan for saving 2 Bytesf n returns a (decimal binary, length) tuple

View Article
Browsing all 30 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>