Results 1 to 11 of 11
Thread: summation of a series
 06202014, 03:13 PM #1Member
 Join Date
 Jun 2014
 Location
 Dhaka
 Posts
 5
 Rep Power
 0
 06202014, 03:26 PM #2Just a guy
 Join Date
 Jun 2013
 Location
 Netherlands
 Posts
 4,836
 Rep Power
 6
Re: summation of a series
Well this already looks a bit strange:
Java Code:public static void main(String[] args){ int i=0,k=10, sum=0; // k = 10 k=k+2; // and then it is increased to 12 ?
"Syntactic sugar causes cancer of the semicolon."  Alan Perlis
 06202014, 04:01 PM #3Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 4,547
 Rep Power
 7
Re: summation of a series
You can also use the increment in your loop. Make it i += 3;
Also, note that each term is simply 3 more than the previous. So the difference of the last and the second term would be
(n + k3)  (n + 3) where k is the number of terms after the first. So the difference is (k1)3 which is divisible by three.
Since 50  13 = 37 is not divisible by 3 your series does not make sense (i.e. 50 is not in the series). With a little thought
you could also derive a general formula for calculating the sum.
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 06202014, 04:08 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,951
 Blog Entries
 7
 Rep Power
 22
Re: summation of a series
I have the stamina of a seal; I lie on the beach instead of running on it.
 06202014, 04:17 PM #5Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 4,547
 Rep Power
 7
Re: summation of a series
Well, I did make an assumption.
Student: What's the next value in this series: 1,3,5,7,?
Prof: 129282
Student: What series is that?
Prof: The one that has 129282 following 1,3,5,7.
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 06202014, 04:41 PM #6Member
 Join Date
 Jun 2014
 Posts
 15
 Rep Power
 0
Re: summation of a series
op,
I'm no rocket surgeon, but I have to say I think your series is a little wacky. I thought the series would be:13 16 19 22 25 28 31 34 37 40 43 46 49 52
 06202014, 05:11 PM #7Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 4,547
 Rep Power
 7
Re: summation of a series
Check out posts #3 and #4 of this thread.
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 06202014, 07:42 PM #8Senior Member
 Join Date
 Apr 2013
 Location
 Sweden
 Posts
 272
 Rep Power
 3
Re: summation of a series
if you just add 3 to every term, fix your loop as Jim829 said.
Or : 1 + 4 + ... + (3n  2) = n(3n  1) / 2
 06202014, 08:01 PM #9
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,951
 Blog Entries
 7
 Rep Power
 22
 06202014, 08:14 PM #10Senior Member
 Join Date
 Apr 2013
 Location
 Sweden
 Posts
 272
 Rep Power
 3
 06212014, 05:49 AM #11
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,951
 Blog Entries
 7
 Rep Power
 22
Re: summation of a series
I do, but it's ugly: for the (x, y) points (0, 10), (1, 13), (2, 16) ... (13, 49), (14, 50) construct a Lagrange (interpolation) polynomial and voila.
link: http://en.wikipedia.org/wiki/Lagrange_polynomial
kind regards,
JosI have the stamina of a seal; I lie on the beach instead of running on it.
Similar Threads

summation in java using for loops
By java157 in forum New To JavaReplies: 3Last Post: 03172011, 09:33 AM 
Summation Problem
By a7x75 in forum New To JavaReplies: 8Last Post: 02052010, 06:38 AM 
Fibonacci summation problem
By xcallmejudasx in forum New To JavaReplies: 3Last Post: 12012009, 07:28 PM 
(Help) Quotient summation with prime numbers
By SapphireSpark in forum New To JavaReplies: 27Last Post: 10242008, 08:28 AM 
(Help) Fraction Summation and Exponents
By SapphireSpark in forum New To JavaReplies: 19Last Post: 10092008, 04:01 AM
Bookmarks