# To CREATE AND PRINT the SERIES 1,2,2,3,3,3,,4,4,4,4…n,n,n,n,n.

Email
 Submitted on: 11/7/2015 1:42:54 AM By: Mr SHINE KADANATTU AYYAPPAN Level: Intermediate User Rating: Unrated Compatibility: C, C++ (general) Views: 3623

In the series ......1,2,2,3,3,3,4,4,4,4,...............n,n,n,n. 1) number of Terms up to last term which is n is =n(n+1)/2 2) Sum Of Terms =1+2+2+3+3+3+4+4+4+4+..............+n+n+n=1+2*2+3*3+4*4+5*5+....n*n =n(n+1)(6n+1)/2 3) Find The General Term..... Here t1=1 ; t2 to t3 =2 ; t4 to t6=3 etc.... Total Number of Terms =n(n+1)/2 n(n+1)/2 th term is n and (n-1)n/2 th term is n-1 which is the last term which is n-1 Then [ (n-1)n/2 + 1 ] th term is n since it is immediately after the last term which is n-1 ok then in general [ (n-1)*n/2 +1 ] th term to [ n(n+1)/2] th term =n where n=1,2,3,4,5....... is the general term ok .You please check it by putting n=1,2,3,4,5..... Now can you find the 5000 th term .Please find it ? Put n(n+1)/2 = 5000 and solve for n ; we will get n^2 +n-10000=0 n= [ -1+Sqroot(1+40001) ] / 2 ; n= 99.50124999==100 ok put n=100 in [ (n-1)*n / 2 + 1 ] & [ n*(n+1) /2 ] we will get 4951 to 5050 ok then 5000th term is 100 ..Is it right ….? In Sequel with the Problem and solution of the Series 1,2,2,3,3,3,,4,4,4,4…n,n,n,n,n. I wrote a Code to print this series up to the last term which is n.First we will input Number of Terms in to terms var. Then the Equation n*(n+1)/2=terms is solved and foind the n where n will be the last term of series .We will calculate (n-1)*n/2 + 1 & n*(n+1)/2 and test whether terms var is between these two values .If yes We will store the series up to the term n*(n+1)/2 and in to an Array and it is printed .I am attaching the Code here .

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

There are no comments on this submission.

Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)