Example: Net Present Value of an Investment

A lady wins a $10 million lottery. The money is to be paid out at the end of each year in $500,000 payments for 20 years. The current treasury bill rate of 6% is used as the discount rate. Here, the net present value of her prize is computed.
using System;
using Imsl.Finance;

public class npvEx1
{
    public static void  Main(String[] args)
    {
        double rate = 0.06;
        double[] value_Renamed = new double[20];
        
        for (int i = 0; i < 20; i++)
            value_Renamed[i] = 500000.0;
        double npv = Finance.Npv(rate, value_Renamed);
        
        Console.Out.WriteLine("The net present value of the $10 " +
                              "million prize is " +    npv.ToString("C"));
    }
}

Output

The net present value of the $10 million prize is $5,734,960.61

Link to C# source.