You are viewing a single comment's thread. Return to all comments →
Haskell
module Main where import Data.Bits countZeroBits :: Integer -> Int countZeroBits n = go n 0 where go :: Integer -> Int -> Int go 0 acc = acc go n acc = go (n `shiftR` 1) (acc + 1 - fromIntegral (n .&. 1)) solve :: Integer -> Integer solve n = 1 `shiftL` countZeroBits n main :: IO () main = readLn >>= print . solve
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Sum vs XOR
You are viewing a single comment's thread. Return to all comments →
Haskell