Java Program to Print Multiplication Table for Any Number Last Updated : 24 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Given a number n as input, we need to print its table, where N>0.Example:Input 1: N = 7Output: 7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 7 * 8 = 56 7 * 9 = 63 7 * 10 = 70Ways to Print Multiplication Table for Any Number in JavaFour ways are shown to Print Multiplication Table for any Number:Using for loop for printing the multiplication table up to 10.Using while loop for printing the multiplication table up to the given range.Using functionUsing recursionPrint Multiplication Table for Any Number in JavaMethod 1: Generating Multiplication Table using for loop up to 10 Java // Java Program to print the multiplication table of the number N using for loop class GFG { public static void main(String[] args) { // number n for which we have to print the // multiplication table. int N = 7; // looping from 1 to 10 to print the multiplication // table of the number. // using for loop for (int i = 1; i <= 10; i++) { // printing the N*i,ie ith multiple of N. System.out.println(N + " * " + i + " = " + N * i); } } } Output7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 7 * 8 = 56 7 * 9 = 63 7 * 10 = 70 Method 2: Generating Multiplication Table using while loop upto any given range Java // Java Program to print the multiplication table of // number N using while loop class GFG { public static void main(String[] args) { // number n for which we have to print the // multiplication table. int N = 7; int range = 18; // looping from 1 to range to print the // multiplication table of the number. int i = 1; // using while loop while (i <= range) { // printing the N*i,ie ith multiple of N. System.out.println(N + " * " + i + " = " + N * i); i++; } } } Output7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 7 * 8 = 56 7 * 9 = 63 7 * 10 = 70 7 * 11 = 77 7 * 12 = 84 7 * 13 = 91 7 * 14 = 98 7 * 15 = 105 7 * 16 = 112 7 * 17 = 119 7 *...Time complexity: O(n) where n is given input rangeAuxiliary space: O(1)Method 3: Generating multiplication table of any number by using function. Java // Java Program to print the multiplication table of number N using function import java.io.*; import java.util.Scanner; class Program { /*function to find table of number*/ static void table(int no) { for (int i = 1; i<=10; i++) { System.out.print(i*no+" "); } } public static void main(String[] args) { System.out.println("Table of 6="); table(6);//calling function System.out.println("\nTable of 5="); table(5);//calling function } } OutputTable of 6= 6 12 18 24 30 36 42 48 54 60 Table of 5= 5 10 15 20 25 30 35 40 45 50 Method 4: Generating multiplication table of any number by using recursion. Java // Java Program to print the multiplication table of the number N using recursion class GFG { public static void tableFun(int number, int i) { // base condition if (i > 10) { return; } System.out.printf("%d * %d = %d\n", number, i, number * i); // recursive method call tableFun(number, i + 1); } public static void main(String[] args) { // number n for which we have to print the // multiplication table. int N = 8; // method call to print table tableFun(N, 1); } } Output8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 8 * 5 = 40 8 * 6 = 48 8 * 7 = 56 8 * 8 = 64 8 * 9 = 72 8 * 10 = 80 Comment More infoAdvertise with us Next Article Java Program to Print Multiplication Table for Any Number L lavishgarg26 Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Practice Tags : Java Similar Reads Java Program to Print the Multiplication Table in a Triangle Form In this form, a table is displayed row and column-wise, in such a way such that in every row, only the entries up to the same column number filled. Example: Input : rows = 6 Output: 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 6 12 18 24 30 36 Approach: The idea is to use nested loops. First, display the col 2 min read Java Program to Multiply two Floating-Point Numbers The float class is a wrapper class for the primitive type float which contains several methods to effectively deal with a float value like converting it to a string representation, and vice-versa. An object of the Float class can hold a single float value. The task is to multiply two Floating point 1 min read Java Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers Schonhage-Strassen algorithm is one of the fastest ways of multiplying very large integer values (30000 to 150000 decimal digits). This algorithm was developed by Arnold Schönhage and Volker Strassen. Though the Furer's algorithm is faster than that of Schonhage-Strassen's algorithm, there are no pr 3 min read Java Program to Print Diamond Shape Star Pattern In this article, we are going to learn how to print diamond shape star patterns in Java. Illustration: Input: number = 7 Output: * *** ***** ******* ********* *********** ************* *********** ********* ******* ***** *** * Methods: When it comes to pattern printing we do opt for standard ways of 6 min read Java Program to Implement the Karatsuba Multiplication Algorithm It is a replacement for the algorithm that we have used since childhood, which is mainly for multiplying numbers of bigger digits. The Karatsuba Algorithm is used for the fast multiplication of large numbers, using a famous technique called as the Divide and Conquer ,developed by Anatolii Alexeevitc 4 min read Like