Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
2 added 141 characters in body
source | link

C, 3232 27 bytes

n(x){return!xx=x?0:x%2+1+3*n(x/2);:0;}

Based on user202729's Java answer. Try it online herehere. Thanks to Kevin Cruijssen for golfing 5 bytes.

Ungolfed version:

n(x) { // recursive function; both argument and return type are implicitly int
    return !x ? 0= // if x=0,implicit return 0
          x :? x % 2 + 1 + 3*n(x/2); // elseif x != 0 return x % 2 + 1 + 3*n(x/2) (recursive call)
    : 0; // else return 0
}

C, 32 bytes

n(x){return!x?0:x%2+1+3*n(x/2);}

Based on user202729's Java answer. Try it online here.

Ungolfed version:

n(x) { // recursive function; both argument and return type are implicitly int
    return !x ? 0 // if x=0, return 0
           : x % 2 + 1 + 3*n(x/2); // else return x % 2 + 1 + 3*n(x/2) (recursive call)
}

C, 32 27 bytes

n(x){x=x?x%2+1+3*n(x/2):0;}

Based on user202729's Java answer. Try it online here. Thanks to Kevin Cruijssen for golfing 5 bytes.

Ungolfed version:

n(x) { // recursive function; both argument and return type are implicitly int
    x = // implicit return
    x ? x % 2 + 1 + 3*n(x/2) // if x != 0 return x % 2 + 1 + 3*n(x/2) (recursive call)
    : 0; // else return 0
}
1
source | link

C, 32 bytes

n(x){return!x?0:x%2+1+3*n(x/2);}

Based on user202729's Java answer. Try it online here.

Ungolfed version:

n(x) { // recursive function; both argument and return type are implicitly int
    return !x ? 0 // if x=0, return 0
           : x % 2 + 1 + 3*n(x/2); // else return x % 2 + 1 + 3*n(x/2) (recursive call)
}