Java Number Sum sumPossitiveIntegerSequencePartial(int start, int end)

Here you can find the source of sumPossitiveIntegerSequencePartial(int start, int end)

Description

sum Possitive Integer Sequence Partial

License

Open Source License

Declaration

public static double sumPossitiveIntegerSequencePartial(int start, int end) 

Method Source Code

//package com.java2s;
/****************************************************
Statistics Online Computational Resource (SOCR)
http://www.StatisticsResource.org//from w w  w .  ja  v a  2 s  .  co m
     
All SOCR programs, materials, tools and resources are developed by and freely disseminated to the entire community.
Users may revise, extend, redistribute, modify under the terms of the Lesser GNU General Public License
as published by the Open Source Initiative http://opensource.org/licenses/. All efforts should be made to develop and distribute
factually correct, useful, portable and extensible resource all available in all digital formats for free over the Internet.
     
SOCR resources are distributed in the hope that they will be useful, but without
any warranty; without any explicit, implicit or implied warranty for merchantability or
fitness for a particular purpose. See the GNU Lesser General Public License for
more details see http://opensource.org/licenses/lgpl-license.php.
     
http://www.SOCR.ucla.edu
http://wiki.stat.ucla.edu/socr
 It s Online, Therefore, It Exists! 
****************************************************/

public class Main {
    public static double sumPossitiveIntegerSequencePartial(int start, int end) {
        double largeSum = .5 * end * (end + 1);
        double smallSum = .5 * start * (start + 1);
        ////System.out.println("sumPossitiveIntegerSequencePartial start = " + start);
        ////System.out.println("sumPossitiveIntegerSequencePartial end = " + end);

        return largeSum - smallSum;

    }
}

Related

  1. sumOfCollectionDouble(Iterable doubleIterable)
  2. sumOfDigits(long n)
  3. sumOfProperDivisors(long num)
  4. sumOr0(Object a, Object b)
  5. sumOverOne(final int n)
  6. sumUp(final Iterable values)