Sort by

recency

|

1431 Discussions

|

  • + 0 comments

    /*This is the simple and easy method to solve this question, i just simply run loop with the 2 number given in problem set and do arithematic calculation and then print as per the guideline, I use for loop cause i know how many time loop is going to run then this section is more easy to understand which i given below: Syntax of for loops:

     **   for (initialisation; condition; increment/decrement)**
    

    System.out.println(n + " x " + i + " = " + (n * i)); n + " x " When you use + with a number and a string, Java converts the number to text and concatenates. If n is 5, this produces "5 x ". + i + " = " Next, Java takes that result and appends the current loop index i, then the literal " = ". If i is 3, you now have "5 x 3 = ". + (n * i) The expression inside parentheses (n * i) is evaluated first (so you multiply two integers). If n = 5 and i = 3, that gives 15, which is then converted to the string "15" and appended. System.out.println(...) Finally, println prints that full string and moves to a new line. Putting it all together, when n = 5 and i = 3, you get: Copy code 5 x 3 = 15 .................................................................If you like my solution,approach hit the one like for appreciation. */

    import java.util.Scanner;

    public class hackerrankloop { public static void main(String[] args) { Scanner sc = new Scanner(System.in);

            int N = sc.nextInt();
            for (int i = 1; i <= 10; i++)
                System.out.println
                        (N + " x " + i + " = " + ( N * i ));
    
        }
    

    }

  • + 0 comments
    import java.io.*;
    import java.math.*;
    import java.security.*;
    import java.text.*;
    import java.util.*;
    import java.util.concurrent.*;
    import java.util.function.*;
    import java.util.regex.*;
    import java.util.stream.*;
    import static java.util.stream.Collectors.joining;
    import static java.util.stream.Collectors.toList;
    
    
    
    public class Solution {
        public static void main(String[] args) throws IOException {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    
            int N = Integer.parseInt(bufferedReader.readLine().trim());
    
            bufferedReader.close();
            
            for (int i=1; i<=10; i++) {
                System.out.println(String.format("%d x %d = %d", N, i, N*i));
            }
        }
    }
    
  • + 0 comments

    java 15

    public static void main(String[] args) throws IOException {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    
            int N = Integer.parseInt(bufferedReader.readLine().trim());
            
            for(int i=1; i<=10; i++){
                System.out.println(N + " x " + i + " = " + N*i);
            }
            
    
            bufferedReader.close();
        }
    
  • + 0 comments

    for (int i=1; i <=10; i++){ System.out.println(N+" x "+i+" = "+N*i); }

  • + 0 comments

    Here is Java Loops 1 problem solution - https://programmingoneonone.com/hackerrank-java-loops-i-problem-solution.html