From 08a0c15d9c765e75b19e3e457fae0005de12f857 Mon Sep 17 00:00:00 2001 From: akshat12000 <56737367+akshat12000@users.noreply.github.com> Date: Fri, 15 Oct 2021 10:32:50 +0530 Subject: [PATCH] =?UTF-8?q?Create=20Brian=5FKernighan=E2=80=99s=5FAlgorith?= =?UTF-8?q?m.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Brian_Kernighan\342\200\231s_Algorithm.cpp" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "Brian_Kernighan\342\200\231s_Algorithm.cpp" diff --git "a/Brian_Kernighan\342\200\231s_Algorithm.cpp" "b/Brian_Kernighan\342\200\231s_Algorithm.cpp" new file mode 100644 index 0000000..82d2950 --- /dev/null +++ "b/Brian_Kernighan\342\200\231s_Algorithm.cpp" @@ -0,0 +1,15 @@ +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int count = 0; // initializing count to 0 + while(n) // run a loop till n is not equal to zero + { + n = n&(n-1); + count++; + } + cout<