@ankur what is the need of prev=((i-)*i)/2;
On Sun, Aug 14, 2011 at 9:51 AM, Ankur Khurana <[email protected]>wrote: > see , we can see that > first lline have 1 number, second have 2 and third have 3 .....and so on. > we can observe that first number of every row is sum of first k narutal > number, where k is the row number. so for k=4, n=((4+1)*4)/2=10; > > so run a for loop, > > > for(int i=1;i<num_rows;i++) > { > prev=((i-)*i)/2; > k=((i+1)*i)/2; > for(int j=k;i;k>prev;j--) > { > cout<<prev<<" "; > } > cout<<endl; > } > > > On Sun, Aug 14, 2011 at 9:43 AM, Dave <[email protected]> wrote: > >> @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 <[email protected]> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > Ankur Khurana > Computer Science > Netaji Subhas Institute Of Technology > Delhi. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- *WITH BEST REGARDS : AASHISH SUMAN MCA FINAL YEAR * *NIT DURGAPUR* *+91-9547969906* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
