The code is in Go. It could be easily ported to other languages. Did you know that you can bitshift a number to the left or right by multiplying a number by 2 or dividing(integer division) a number by 2 respectively? Anyway, let’s start by getting the least significant bit of a number: Then let’s…