Print first m multiples of n in C#



To print m multiples of n, first set the value of m and n −

 int n = 6, m = 1; 

Now loop through the value of m, increment it and multiply with n on every iteration −

 while (m <= 5) { // multiply n*m m++; } 

Let us see the complete code −

Example

Live Demo

 using System; public class Demo { public static void Main() { int n = 6, m = 1; while (m <= 5) { Console.WriteLine(" {0} 
", n * m); m++; } } }

Output

 6 12 18 24 30 
Updated on: 2019-07-30T22:30:23+05:30

678 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements