Skip to content

Instantly share code, notes, and snippets.

View rabiulcste's full-sized avatar

Rabiul Awal rabiulcste

View GitHub Profile
int countSetBits(unsigned int n)
{
unsigned int count = 0;
while(n)
{
count += n & 1; // ভাগশেষ ০ নাকি ১ । যদি ১ হয় তাহলে কাউন্টের মান বেড়ে যাবে ।
n >>= 1; // n কে দুই দিয়ে ভাগ করা হচ্ছে ।
}
return count;
}
int main()
{
int n, cnt = 0;
cin >> n;
while(n)
{
n &= (n-1);
cnt++;
}
cout << cnt <<endl;
void primeFactors(int n)
{
// Print the number of 2s that divide n
while (n%2 == 0)
{
printf("%d ", 2);
n = n/2;
}
// n must be odd at this point. So we can skip one element (Note i = i +2)
void multiply(char a[], char b[], char res[])
{
int i, j, k, mul, carry;
// if one number is zero, then result obviously zero
if(strcmp(a, "0") == 0 || strcmp(b, "0") == 0)
{
strcpy(res, "0");
return;
}