Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 37 bytes

JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$n\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

#JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$n\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$n\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

edited body
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

#JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$s\$\$n\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

#JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$s\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

#JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$n\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

added a description of both versions
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

#JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$s\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

#JavaScript (ES6), 37 bytes

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

#JavaScript (ES6), 37 bytes

Looks for the smallest \$n\$ such that the decimal representation of \$p=n\times k\$ is made exclusively of \$0\$'s and \$1\$'s.

f=(k,p=k)=>/[2-9]/.test(p)?f(k,p+k):p 

Try it online! (some test cases removed because of recursion overflow)


#JavaScript (ES6), 41 bytes

Looks for the smallest \$n\$ such that \$k\$ divides the binary representation of \$s\$ parsed in base \$10\$.

k=>(g=n=>(s=n.toString(2))%k?g(n+1):s)(1) 

Try it online! (all test cases)

added a shorter version
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading