A number is said to be a sparse number if in binary representation of the number no two or more consecutive bits are set. Write a function to check if a given number is Sparse or not.
Euclid’s algorithm is used to find GCD of two numbers. There are mainly two versions of algorithm. Version 1 (Using subtraction) Version 2 (Using modulo operator) Which of the above two is more efficient? Version 1 can take linear time to find the GCD, consider the situation when one of the given numbers is much… Read More »
A magic number is defined as a number which can be expressed as a power of 5 or sum of unique powers of 5. First few magic numbers are 5, 25, 30(5 + 25), 125, 130(125 + 5), ….
Given an integer, write a function that calculates ⌈7n/8⌉ (ceiling of 7n/8) without using division and multiplication operators.
Write a function subtract(x, y) that returns x-y where x and y are integers. The function should not use any of the arithmetic operators (+, ++, –, -, .. etc).
Given an integer n, calculate square of a number without using *, / and pow(). Examples: Input: n = 5 Output: 25
In C, we can specify size (in bits) of structure and union members. The idea is to use memory efficiently when we know that the value of a field or group of fields will never exceed a limit or is withing a small range.
Given an integer ‘x’, write a C function that returns true if binary representation of x is palindrome else return false.
A nibble is a four-bit aggregation, or half an octet. There are two nibbles in a byte.
Difficulty Level: Rookie Given a number n and a value k, turn of the k’th bit in n.
Given a number n, write a function that returns true if n is divisible by 9, else false. The most simple way to check for n’s divisibility by 9 is to do n%9.