Skip to main content
2 of 2
golfed a byte
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 35 34 bytes

f=n=>n?[...f(n>>=1),!n|n%2||-1]:[]

Test snippet

let f=n=>n?[...f(n>>=1),!n|n%2||-1]:[];

[25, 47, 1, 3, 1234567].map(x => console.log(x + ":", JSON.stringify(f(x))))

ETHproductions
  • 50.1k
  • 6
  • 94
  • 240