Skip to main content
added 197 characters in body
Source Link

R, 7575 68 bytes

  • -7 bytes by rewriting if and digit extraction (pajonk)
\f=\(b){if`if`(b>1&all((K=b%%10^K=b%/%10^(X=1X=0:nchar(b))%/%10^(X-1)%%10)<2))b=f,f(sum(2^X/2*K2^X*K));b},b)

Attempt This Online!Attempt This Online!

A recursive function: the first if-condition is checking whether the input is not 1 or 0; the second condition checks whether there are only the digits 0 or 1 in the generated on the fly K vector. Then the function is called again, with the b converted to its decimal form as the input. Outside ofOutside of if In the ifelse b-clause b is output (outputted ?).

R, 75 bytes

\(b){if(b>1&all((K=b%%10^(X=1:nchar(b))%/%10^(X-1))<2))b=f(sum(2^X/2*K));b}

Attempt This Online!

A recursive function: the first if-condition is checking whether the input is not 1 or 0; the second condition checks whether there are only the digits 0 or 1. Then the function is called again, with the b converted to its decimal form as the input. Outside of if b is output (outputted ?).

R, 75 68 bytes

  • -7 bytes by rewriting if and digit extraction (pajonk)
f=\(b)`if`(b>1&all((K=b%/%10^(X=0:nchar(b))%%10)<2),f(sum(2^X*K)),b)

Attempt This Online!

A recursive function: the first if-condition is checking whether the input is not 1 or 0; the second condition checks whether there are only the digits 0 or 1 in the generated on the fly K vector. Then the function is called again, with the b converted to its decimal form as the input. Outside of if In the else-clause b is output (outputted ?).

Source Link

R, 75 bytes

\(b){if(b>1&all((K=b%%10^(X=1:nchar(b))%/%10^(X-1))<2))b=f(sum(2^X/2*K));b}

Attempt This Online!

A recursive function: the first if-condition is checking whether the input is not 1 or 0; the second condition checks whether there are only the digits 0 or 1. Then the function is called again, with the b converted to its decimal form as the input. Outside of if b is output (outputted ?).