Series

1. Program

How to Print this series ? 1, 2, 6, 15, 31, 56 .......N

import java.util.Scanner; class Series { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter the range greater then 0 : "); int n = sc.nextInt(); int i = 1, j=1; if(n>0) { while(i <= n) { System.out.print(i +" "); i = i + (j*j); j++; } } else{ System.out.print("Enter the range greater then 0 "); } } }