let n = 13
let s = [...n.toString(2)].map(Number).reverse()


function f(n){
    if(n == 1) return "1"
    let m = Math.floor(n/2)
    return n%2 ? `(2*${f(m)}+1)`: `(2*${f(m)})`
}

let st = f(n)
console.log(st, eval(st))

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: