Write a program to print n multiples of x in Java
Answers
Answer:
import java.util.*;
class multipleN_X
{
public static void main(String[] aars)
{
Scanner input = new Scanner(System.in);
System.out.print("N = ");
int N = input.nextInt();
System.out.println();
System.out.print("X = ");
int X = input.nextInt();
System.out.println("Mutiples Of N ");
for(int i=1;i<=N;i++)
{
int k=i*N;
if(k%X == 0)
{
System.out.println(X+"is divisible by "+k+" So loop stops ");
break;
}
else
{
System.out.println(k);
}
}
}
}
Explanation:
..............................................................................................................................................................................................................................................................................................................
Explanation: