Nested for loop to print multiplication tables up to a certain number. Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report A nested for loop is used to print multiplication tables up to a certain number by generating rows and columns of multiplication results. Here's the explanation of how to achieve this using nested loops In this article, we will discuss how to print multiplication tables up to a certain number with its working example in the R Programming Language using R for loop conditions. Syntax:max_number <- 10 # Change this to the desired maximum numberfor (i in 1:max_number) { for (j in 1:10) { # Multiplication up to 10 cat(i, "x", j, "=", i * j, "\n") } cat("\n") # Print a blank line after each table}Example 1: Nested for loop to print multiplication tables R max_number <- 5 for (i in 1:max_number) { for (j in 1:10) { cat(i, "x", j, "=", i * j, "\n") } cat("\n") } Output: Multiplication table for 1 :1 x 1 = 1 1 x 2 = 2 1 x 3 = 3 1 x 4 = 4 1 x 5 = 5 1 x 6 = 6 1 x 7 = 7 1 x 8 = 8 1 x 9 = 9 1 x 10 = 10 Multiplication table for 2 :2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 2 x 10 = 20 Multiplication table for 3 :3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30 Multiplication table for 4 :4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16 4 x 5 = 20 4 x 6 = 24 4 x 7 = 28 4 x 8 = 32 4 x 9 = 36 4 x 10 = 40 Multiplication table for 5 :5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50 Set the value of the variable max_number to 5.Start an outer for loop that iterates through numbers from 1 to the value of max_number.Start an inner for loop that iterates through numbers from 1 to 10 for each value of i.Using the cat() function, print the multiplication expression in the format "i x j = i * j", followed by a newline character.End of the inner for loop.Print a blank line to separate the multiplication tables for each i value.End of the outer for loop.Example 2: Nested for loop to print multiplication tables up to a certain number. R max_number <- 13 for (i in 11:max_number) { for (j in 1:10) { cat(i, "x", j, "=", i * j, "\n") } cat("\n") } Output: 11 x 1 = 11 11 x 2 = 22 11 x 3 = 33 11 x 4 = 44 11 x 5 = 55 11 x 6 = 66 11 x 7 = 77 11 x 8 = 88 11 x 9 = 99 11 x 10 = 110 12 x 1 = 12 12 x 2 = 24 12 x 3 = 36 12 x 4 = 48 12 x 5 = 60 12 x 6 = 72 12 x 7 = 84 12 x 8 = 96 12 x 9 = 108 12 x 10 = 120 13 x 1 = 13 13 x 2 = 26 13 x 3 = 39 13 x 4 = 52 13 x 5 = 65 13 x 6 = 78 13 x 7 = 91 13 x 8 = 104 13 x 9 = 117 13 x 10 = 130Set the value of the variable max_number to 13.Start an outer for loop that iterates through numbers from 1 to the value of max_number.Start an inner for loop that iterates through numbers from 1 to 10 for each value of i.Using the cat() function, print the multiplication expression in the format "i x j = i * j", followed by a newline character.End of the inner for loop.Print a blank line to separate the multiplication tables for each i value.End of the outer for loop. Comment More infoAdvertise with us Next Article Table 20 to 25 - Multiplication Table Chart and 20-25 Times Table A anjugaeu01 Follow Improve Article Tags : R Language Similar Reads Kth Smallest Number in Multiplication Table Given three integers m, n, and k. Consider a grid of m * n, where mat[i][j] = i*j (1 based indexing). The task is to return the k'th smallest element in the m*n multiplication table.Examples: Input: m = 3, n = 3, k = 5Output: 3Explanation:The 5th smallest element is 3. Input: m = 2, n = 3, k = 6Outp 13 min read Nested for Loop to Print a Pattern. A nested for loop in R is used when we want to iterate through multiple dimensions, such as rows and columns of a matrix, or for creating patterns. we will discuss how to print multiplication tables up to a certain number with its working example in the R Programming Language using R for loop condit 3 min read Table 20 to 25 - Multiplication Table Chart and 20-25 Times Table Multiplication Tables of 20, 21, 22, 23, 24, and 25 are provided here. Tables from 20 to 25 is a list of tables that contain multiplication of numbers 20 to 25 with integers 1 to 10. For eg. a multiplication table of 21 will show results when 21 is multiplied by numbers 1 to 10. Tables in Maths are 5 min read How to Teach Multiplication Tables to Kids Teaching multiplication tables effectively involves using a variety of strategies to engage students and help them understand and memorize the tables. In this article, we will study about what is mathematics, the rules of multiplication, the properties of multiplication, multiplication signs, multip 7 min read CSES Solutions - Multiplication Table Find the middle element when the numbers in an n à n multiplication table are sorted in increasing order. It is assumed that n is odd. For example, the 3 à 3 multiplication table is as follows: 1 2 32 4 63 6 9 The numbers in increasing order are [1,2,2,3,3,4,6,6,9], so the answer is 3 Example:Input: 4 min read How to Create a Nested For Loop in R? A loop in a programming language is a sequence of instructions executed one after the other unless a final condition is met. Using loops is quite frequent in a program. Need of a loop Let us consider a scenario where we want to print natural numbers from 1 to 3. We can simply print them one by one. 6 min read Like