I am trying to make a program that finds the sum of:

∑ (2n+1)!

In this program the user inputs the upper limit of the program and the lower limit is always 0.

So if the user input the value 2 for the upper limit the sum would be:

[2(0)+1]! + [2(1)+1]! + [2(2)+1]!

= 1! + 3! + 5!

= 1 + 6 + 120

=127

Since java does not have a factorial function I made the following program:

import java.io.*;

public class factorial

{

public static void main(String args[]) throws IOException

{

BufferedReader keybd = new BufferedReader(new InputStreamReader(System.in));

int n;

System.out.print("Input a value for the upper limit: ");

n = Integer.parseInt(keybd.readLine());

int factorial=1;

for (int i=2; i<=n; i++)

{

factorial=factorial*i;

}

System.out.println(factorial);

}

}

This program calculates factorials (ie if the user inputs 5 into the above program it will about the answer of 120)

I don't know how I can incorporate the factorial to find the sum of ∑ (2n+1)!