fork download
  1. # Function to generate and print the multiplication table
  2. multiplication_table <- function(num, limit = 10) {
  3. # Print the header
  4. cat("Multiplication Table for", num, ":\n")
  5.  
  6. # Loop to generate the table
  7. for (i in 1:limit) {
  8. result <- num * i
  9. cat(num, "x", i, "=", result, "\n")
  10. }
  11. }
  12.  
  13. # Example: Generating multiplication table for 7
  14. num <- 7
  15. multiplication_table(num)
  16.  
Success #stdin #stdout 0.31s 40632KB
stdin
Standard input is empty
stdout
Multiplication Table for 7 :
7 x 1 = 7 
7 x 2 = 14 
7 x 3 = 21 
7 x 4 = 28 
7 x 5 = 35 
7 x 6 = 42 
7 x 7 = 49 
7 x 8 = 56 
7 x 9 = 63 
7 x 10 = 70