**Objective**

In this challenge, we’re going to use loops to help us do some simple math.

**Task**

Given an integer N print its first 10 multiples. Each multiple N x i (where 1<= i <=10 ) should be printed on a new line in the form: `N x i = result`

.

**Input Format**

A single integer.

**Output Format**

Print 10 lines of output; each line i contains the of in the form:

`N x i = result`

.

import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;public class Solution {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int n = in.nextInt();

for(int i=1;i<=10;i++)

{

System.out.println(n + ” x ” +i+” = “+(n*i));

}

}

}

The another way one can do it is

import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;public class Solution {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int n = in.nextInt();

int i=1;while(i<=10)

{

System.out.println(n + ” x ” +i+” = “+(n*i));i+=1;

}

}

}

So basically there are 4 loops in java

- for loop
- while loop
- do while loop
- for each

In this post you’ve seen both the for loop and while loop , next post will share the remaining loop structures

Feel free to comment.

You actually make it seem so easy with your presentation but I find this matter to be actually something that I think I’d by no means understand. It sort of feels too complicated and extremely large for me. I’m having a look ahead on your next publish, I’ll attempt to get the hold of it!

LikeLike

Thank you a bunch for sharing this with all folks you really understand what you are talking approximately! Bookmarked. Kindly also consult with my web site =). We could have a hyperlink alternate arrangement among us!

LikeLike