HCF of two Numbers | Python Program
The HCF is a mathematical term for the Highest Common Divisor of two or more numbers. It is the highest common divisor that completely divides two or more numbers without leaving any remainder. Therefore, it is also known as the Greatest Common Factor (GCD) of two numbers.
LCM of two Numbers | Python Programming
LCM (Least Common Multiple) of two numbers is the smallest number which can be divided by both numbers.
For example, LCM of 15 and 20 is 60, and LCM of 5 and 7 is 35.
A simple solution is to find all prime factors of both numbers, then find union of all factors present in both numbers. Finally, return the product of elements in union.
Pattern of string | Python Programming
Given a string S of length N, find the pattern of the strings as shown below in the examples.
Example 1:
Input: S = "GeeK"
Output: Geek
Gee
Ge
G
Explanation: Decrease one character
after each line
Example 2:
Input: S = "G*g"
Output: G*g
G*
G
Explanation: Decrease one character
after each line