@Rahul: More elegant that what? Dave
On Aug 13, 11:55 pm, Rahul <raikra...@gmail.com> wrote: > @Beginner > If You Know How to implement a series whose difference in terms form An > Arithmetic Progression > > Then Is quite easy > to print the (n)TH Line > Add n to the highest number seen so far and then subtract the 1 for n times > (p = n-- , check for p ) > > @Everyone Else > Can anyone one think of a more elegant method , to find #rows > > Rahul > > On Sun, Aug 14, 2011 at 10:09 AM, Ankur Khurana > <ankur.kkhur...@gmail.com>wrote: > > > > > to print from 10 to 7 in the row number 4. here prev will be 6. > > > On Sun, Aug 14, 2011 at 10:05 AM, AASHISH SUMAN <aashish.barn...@gmail.com > > > wrote: > > >> @ankur > > >> what is the need of > >> prev=((i-)*i)/2; > > >> On Sun, Aug 14, 2011 at 9:51 AM, Ankur Khurana > >> <ankur.kkhur...@gmail.com>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 <dave_and_da...@juno.com> 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 <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. > > >>> -- > >>> 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 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. > > >> -- > >> *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 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. > > > -- > > 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 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. -- 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.