To print m multiples of n, first set the values of m and n -
int n = 6, m = 1;
Now loop through the values of m, incrementing it and multiplying by n on each iteration -
while (m <= 5) { // multiply n*m m++; }
Let’s see the complete code −
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++; } } }
6 12 18 24 30
The above is the detailed content of Print first m multiples of n in C#. For more information, please follow other related articles on the PHP Chinese website!