Java Loops II

Sort by

recency

|

3216 Discussions

|

  • + 0 comments

    geeting time out error

  • + 0 comments
    public static void main(String []argh){
        Scanner in = new Scanner(System.in);
        int t=in.nextInt();
        for(int i=0;i<t;i++){
            int a = in.nextInt();
            int b = in.nextInt();
            int n = in.nextInt();
            int sum = a;
            int pow = 1;
            for (int j = 0; j < n; j++ ) {
                sum += b * pow;
                System.out.print(sum + " ");
                pow <<= 1;
            }
            System.out.println();
        }
        in.close();
    }
    
  • + 0 comments

    import java.util.; import java.io.;

    class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int t=in.nextInt();

        for(int i=0;i<t;i++){
            int a = in.nextInt();
            int b = in.nextInt();
            int n = in.nextInt();
    
            for(int j=0;j<n;j++)
            {
                a=a+ (int)Math.pow(2, j) *b;
                System.out.print(a+" ");
    
            }
            System.out.println();
        }
        in.close();
    }
    

    }

  • + 0 comments

    java can be use in eithcal hacking

  • + 0 comments

    Java Loops II" explores how nested loops work in Java, allowing dynamic calculations based on user input. It's often used to generate series or patterns through arithmetic logic. This concept is especially useful in areas like network simulations or data processing tasks.