Re: [algogeeks] Re: Printing a Number triangle

2011-08-14 Thread muruga vel
I  was asked to find out the no of rows given n . i.e. how we say 4 rows for
10 ???
On 14 Aug 2011 10:54, sagar pareek sagarpar...@gmail.com wrote:
 here is sudo code

 take two variables

 int max=1;
 int count=1;
 int i,total_no_of_rows;

 while(total_no_of_rows--)
 {
 for(i=0;icount;i++)
 {
 printf(%d ,max-i);
 }
 printf(\n);
 count++;
 max+=count;
 }

 On Sun, Aug 14, 2011 at 10:25 AM, 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;inum_rows;i++)
 {
 prev=((i-)*i)/2;
 k=((i+1)*i)/2;
 for(int j=k;i;kprev;j--)
 {
 coutprev ;
 }
 coutendl;
 }


 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.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

 --
 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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-14 Thread Rahul
Dave has given you the formula
Rahul


On Sun, Aug 14, 2011 at 7:49 PM, muruga vel murugavidya1...@gmail.comwrote:

 I  was asked to find out the no of rows given n . i.e. how we say 4 rows
 for 10 ???
 On 14 Aug 2011 10:54, sagar pareek sagarpar...@gmail.com wrote:
  here is sudo code
 
  take two variables
 
  int max=1;
  int count=1;
  int i,total_no_of_rows;
 
  while(total_no_of_rows--)
  {
  for(i=0;icount;i++)
  {
  printf(%d ,max-i);
  }
  printf(\n);
  count++;
  max+=count;
  }
 
  On Sun, Aug 14, 2011 at 10:25 AM, 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.comwrote:
 
  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;inum_rows;i++)
  {
  prev=((i-)*i)/2;
  k=((i+1)*i)/2;
  for(int j=k;i;kprev;j--)
  {
  coutprev ;
  }
  coutendl;
  }
 
 
  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.
 
 
 
 
  --
  **Regards
  SAGAR PAREEK
  COMPUTER SCIENCE AND ENGINEERING
  NIT ALLAHABAD
 
  --
  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 

Re: [algogeeks] Re: Printing a Number triangle

2011-08-14 Thread Anika Jain
plz tell me that for this triangle.. if 12 is given then what to do?

On Sun, Aug 14, 2011 at 7:49 PM, muruga vel murugavidya1...@gmail.comwrote:

 I  was asked to find out the no of rows given n . i.e. how we say 4 rows
 for 10 ???
 On 14 Aug 2011 10:54, sagar pareek sagarpar...@gmail.com wrote:
  here is sudo code
 
  take two variables
 
  int max=1;
  int count=1;
  int i,total_no_of_rows;
 
  while(total_no_of_rows--)
  {
  for(i=0;icount;i++)
  {
  printf(%d ,max-i);
  }
  printf(\n);
  count++;
  max+=count;
  }
 
  On Sun, Aug 14, 2011 at 10:25 AM, 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.comwrote:
 
  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;inum_rows;i++)
  {
  prev=((i-)*i)/2;
  k=((i+1)*i)/2;
  for(int j=k;i;kprev;j--)
  {
  coutprev ;
  }
  coutendl;
  }
 
 
  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.
 
 
 
 
  --
  **Regards
  SAGAR PAREEK
  COMPUTER SCIENCE AND ENGINEERING
  NIT ALLAHABAD
 
  --
  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 

Re: [algogeeks] Re: Printing a Number triangle

2011-08-14 Thread Rahul
8 times 12 is 96
96 + 1
is
97
take sqrt(97)
9.8488578017961047217462114149176

now 9.8488578017961047217462114149176 minus 1
EQUALS
8.8488578017961047217462114149176
Half IT
And Take The Ceiling of it = 5





On Sun, Aug 14, 2011 at 8:05 PM, Anika Jain anika.jai...@gmail.com wrote:

 plz tell me that for this triangle.. if 12 is given then what to do?

 On Sun, Aug 14, 2011 at 7:49 PM, muruga vel murugavidya1...@gmail.comwrote:

 I  was asked to find out the no of rows given n . i.e. how we say 4 rows
 for 10 ???
  On 14 Aug 2011 10:54, sagar pareek sagarpar...@gmail.com wrote:
  here is sudo code
 
  take two variables
 
  int max=1;
  int count=1;
  int i,total_no_of_rows;
 
  while(total_no_of_rows--)
  {
  for(i=0;icount;i++)
  {
  printf(%d ,max-i);
  }
  printf(\n);
  count++;
  max+=count;
  }
 
  On Sun, Aug 14, 2011 at 10:25 AM, 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.comwrote:
 
  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;inum_rows;i++)
  {
  prev=((i-)*i)/2;
  k=((i+1)*i)/2;
  for(int j=k;i;kprev;j--)
  {
  coutprev ;
  }
  coutendl;
  }
 
 
  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.
 
 
 
 
  --
  **Regards
  SAGAR PAREEK
  COMPUTER SCIENCE AND ENGINEERING
  NIT ALLAHABAD
 
  --
  You received this message because you are subscribed to the Google
 Groups 

Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread Ankur Khurana
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;inum_rows;i++)
{
prev=((i-)*i)/2;
k=((i+1)*i)/2;
for(int j=k;i;kprev;j--)
   {
coutprev ;
}
coutendl;
}


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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread AASHISH SUMAN
@ankur

what is the need of
prev=((i-)*i)/2;




On Sun, Aug 14, 2011 at 9:51 AM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 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;inum_rows;i++)
 {
 prev=((i-)*i)/2;
 k=((i+1)*i)/2;
 for(int j=k;i;kprev;j--)
{
 coutprev ;
 }
 coutendl;
 }


 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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread Ankur Khurana
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.comwrote:

 @ankur

 what is the need of
 prev=((i-)*i)/2;




 On Sun, Aug 14, 2011 at 9:51 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 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;inum_rows;i++)
 {
 prev=((i-)*i)/2;
 k=((i+1)*i)/2;
 for(int j=k;i;kprev;j--)
{
 coutprev ;
 }
 coutendl;
 }


 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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread Rahul
@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.comwrote:

 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.comwrote:

 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;inum_rows;i++)
 {
 prev=((i-)*i)/2;
 k=((i+1)*i)/2;
 for(int j=k;i;kprev;j--)
{
 coutprev ;
 }
 coutendl;
 }


 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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread sagar pareek
here is sudo code

take two variables

int max=1;
int count=1;
int i,total_no_of_rows;

while(total_no_of_rows--)
{
 for(i=0;icount;i++)
 {
   printf(%d ,max-i);
 }
  printf(\n);
  count++;
  max+=count;
}

On Sun, Aug 14, 2011 at 10:25 AM, 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.comwrote:

 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;inum_rows;i++)
 {
 prev=((i-)*i)/2;
 k=((i+1)*i)/2;
 for(int j=k;i;kprev;j--)
{
 coutprev ;
 }
 coutendl;
 }


 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.




-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD

-- 
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.