In this video, we will write a Javascript program to generate multiplication of table.
Here we will see 2 different methods for this task:
1. Using For Loop
2. Using Recursive approach
1. Using for loop: In this method, we use for loop to generate a table. Here first we define a number and run a for loop from 1 to 10. After that multiply i with N and print the table.
Time and Space complexity: O(1)
2. Using Recursive Method:
In this method, we will create a recursive function to generate the multiplication table. This function will take as input the local variable and the number that we are multiplying. The function will then return a string that corresponds to the multiplication table that we want to generate.
Time complexity: O(N)
Space complexity: O(1)
Javascript program to generate multiplication table : https://www.geeksforgeeks.org/javascript-program-to-print-multiplication-table-of-a-number/