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
using System;
public class Demo {
public static void Main() {
int n = 6, m = 1;
while (m <= 5) {
Console.WriteLine(" {0} \n ", n * m);
m++;
}
}
}
Output
6 12 18 24 30