Here you can find the source of sum0ToN(int n)
public static int sum0ToN(int n)
//package com.java2s; // it under the terms of the GNU General Public License as published by // public class Main { /**//from w w w .ja va2 s. c o m * Returns the sum of integers from 0 up to n. */ public static int sum0ToN(int n) { if (n < 0) { throw new IllegalArgumentException("Argument must be >= 0: " + n); } return n * (n + 1) / 2; } }