@Beginner: The largest number n in row r satisfies n = (r^2 + r) / 2. So using the Quadratic Formula gives
r = ( sqrt( 8*n + 1 ) - 1 ) / 2. For the row number r for any n (not necessarily the largest one in a row), r = ceil( sqrt( 8*n + 1 ) - 1 ) / 2 ) where ceil( x ) is the smallest integer not exceeding x. Dave On Aug 13, 10:22 pm, Beginner <murugavidya1...@gmail.com> wrote: > How to print this triangle? > 1 > 3 2 > 6 5 4 > 10 9 8 7 > and how to find the number of rows if n is given? > For ex if n=10 how to find num of rows=4?? > Is it Log 10 to the base of 2!!!!!! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.