![]() |
VOOZH | about |
Given two positive integers N and K, the task is to print the Multiplication table of N till Kth multiple.
Examples:
Input: N = 6, K = 5
Output:
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30Input: N = 9, K = 3
Output:
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
Approach:
The problem can be solved by running a loop from i = 1 to i = K and for every iteration print the product of N and i as the answer.
Step-by-step approach:
Below is the implementation of the above approach:
The multiplication table of 6 6 * 1 = 6 6 * 2 = 12 6 * 3 = 18 6 * 4 = 24 6 * 5 = 30 6 * 6 = 36 6 * 7 = 42 6 * 8 = 48 6 * 9 = 54 6 * 10 = 60
Time Complexity: O(K), where K is the number of rows in the multiplication table.
Auxiliary Space: O(1)