Print All the Subsets of a Given Set (Power Set)

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, PowerSet of any given set S, PS(S) is set of all subsets of S including empty set. Example: S ={1,2,3} PS(S): {{ᵩ}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}. Approach: … Read more

Goldbach’s Conjecture

Goldbach’s conjecture – Every even integer greater than 2 can be represented as the sum of two primes numbers.

Example:

Given Number : 200

Prime Numbers are 3 197
Prime Numbers are 7 193
Prime Numbers are 19 181
Prime Numbers are 37 163
Prime Numbers are 43 157
Prime Numbers are 61 139
Prime Numbers are 73 127
Prime Numbers are 97 103

Approach:

Read more

Convert Decimal into Irreducible Fraction

Objective: Given a decimal number, convert it into irreducible fraction. Irreducible Fraction : An irreducible fraction is a fraction in which the numerator and denominator are integers that have no other common divisors than 1. Ex: 1/4, 5/20, 1/2 etc Example: Input: 0.35 Output : 7/20 Input: 1.2 Output : 6/5 Approach: Split using decimal … Read more