Jump to content

Check out our Community Blogs

Recent Status Updates

  • Photo
      10 Jul

    True or just funny? One day programmers will become obsolete as they make errors and programs don't :D

    Show comments (4)
View All Updates

Developed by TechBiz Xccelerator
- - - - -

Nested For Loop [EXAMPLES!]

nested loop for loop loop

  • Please log in to reply
121 replies to this topic

#121 pamesh


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 23 October 2015 - 06:24 AM

Can you help me with Java code which gives following output:


1  1 

12 3

123 6

1234 10

12345 15


Basically sequence and sum of the numbers at the end with a gap.  



  • 0

#122 lespauled


    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1351 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 23 October 2015 - 06:44 AM

As a practice, we don't do homework for you (although this thread seems to refute that).  But, if you actually try, and find a problem, we will help.  


With that said, you already have over half of the pattern figured out.  


Numbers and a sum of those numbers at the end.


The part to figure out is rest, which is very straightforward when you see it.


Think of this portion of the problem in the terms of Rows and Columns, and the solution should come to you.

  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

Also tagged with one or more of these keywords: nested loop, for loop, loop