Category Archives: GFacts

GFact 23 | (Bocard’s problem)

Bocard’s problem is to find values of m and n such that n!+1 = m2 For example, a pair (4, 5) solves the above equation. We have n = 4, m = 5. 4! + 1 = 24 + 1 = 25 = 52. A pair (n, m) that solves above is called Brown Number.… Read More »

GFact 22 | (2^x + 1 and Prime)

A number of the form 2x + 1 (where x > 0) is prime if and only if x is a power of 2, i.e., x = 2n. So overall number becomes 22n + 1. Such numbers are called Fermat Number (Numbers of form 22n + 1). The first few Fermet numbers are 3, 5,… Read More »

G-Fact 21 | Collatz Sequence

Starting with any positive integer N, we define the Collatz sequence corresponding to N as the numbers formed by the following operations: N → N/2 ( if N is even) N → 3N + 1 (if N is odd) i.e. If N is even, divide it by 2 to get N/2. If N is odd,… Read More »

G-Fact 19 (Logical and Bitwise Not Operators on Boolean)

Most of the languages including C, C++, Java and Python provide the boolean type that can be either set to False or True. Consider below programs that use Logical Not (or !) operator on boolean. The outputs of above programs are as expected, but the outputs following programs may not be as expected if we… Read More »

G-Fact 17

Storage class of a variable determines whether the item has a global or local lifetime. In C, typedef is considered as a storage class like other storage classes (auto, register, static and extern),

G-Fact 16

Predict the output of following program.

G-Fact 15

Atomic Operation What is an atomic operation? An idea of atomic operation helps in understanding reentrancy, critical section, thread safety, synchronization primitives, etc… (we will have upcoming articles on each).

G-Fact 14

In C, a structure cannot have static members, but in C++ a structure can have static members.