We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Java
  3. Introduction
  4. Java Loops II
  5. Discussions

Java Loops II

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • 16bce169 3 years ago+ 0 comments

    If you use "println" then every number will be printed in next line..........

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

            int sum=0;
            sum += a + (pow(2,0)*b);
            System.out.print(sum+" ");
            for(int j=1;j<n;j++)
            {
                sum = sum + (b*pow(2,j));
                System.out.print(sum+" ");
            }
            System.out.println();
            sum=0;
    
    
        }
        in.close();
    }
    static int pow(int a,int b)
    {
        if(b>0)
        {
            return(a*pow(a,b-1));
        }
        else
        {
            return 1;
        }
    }
    
    3|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature