Mathematical Library Documentation (NuGet Package)

A library for functions used in solving Project Euler problems along with some basic statistical functions, coded in F#

The Project Euler functions cover primes, factorials, narcissism, random numbers, arrays and series/sequences (collatz, terra, Fibonacci).

The statistical functions cover variance, standard deviation, and sum of squares.

Publishing to NuGet is a new experience for me, so use at your own risk, but feel free to contact me if you have issues.

Euler Library Tests


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using Microsoft.FSharp.Collections;

namespace Libraries.Test
{
    [TestClass]
    public class EulerLibTests
    {
        [TestMethod()]
        public void FactorialTest()
        {
            Int32 result = EulerLib.Factorial(3,1);
            Assert.AreEqual(result, 6);
        }

        [TestMethod()]
        public void GetPrimesTest()
        {
            var result = EulerLib.GetPrimes(100);
            Assert.IsNotNull(result);
        }

        [TestMethod()]
        public void IsPrimeTest()
        {
            Boolean resultPrimeTrue = EulerLib.IsPrime(7);
            Assert.IsTrue(resultPrimeTrue);

            Boolean resultPrimeFalse = EulerLib.IsPrime(6);
            Assert.IsFalse(resultPrimeFalse);
        }

        [TestMethod()]
        public void CollatzSequenceCountTest()
        {
            int result = EulerLib.CollatzSequenceCount(13, 1);
            Assert.IsTrue(result == 10);
        }

        [TestMethod()]
        public void RandomArrayTest()
        {
            double[] result = EulerLib.RandomArray(30);
            Assert.IsTrue(result.Length == 30);
        }

    }
}

Stat Library Tests


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Libraries.Test
{
    [TestClass]
    public class StatTests
    {
        public StatTests()
        {

        }

        [TestMethod]
        public void StdDevTest()
        {
            double result = Stat.StdDev(new double[] { 1.1, 2.2, 3.3 });
            Assert.IsTrue(result > 0);
        }

        [TestMethod]
        public void VarianceTest()
        {
            double result = Stat.variance(new double[] { 1.1, 2.2, 3.3 });
            Assert.IsTrue(result > 0);
        }

        [TestMethod]
        public void SumOfSquaresTest()
        {
            double result = Stat.sumOfSquares(new double[] { 1.1, 2.2, 3.3 });
            Assert.IsTrue(result > 0);
        }

        [TestMethod]
        public void SquaredDifferenceArrayTest()
        {
            double[] result = Stat.SquaredDifferenceArray(new double[] { 1.1, 2.2, 3.3 });
            Assert.IsTrue(result.Length > 0);
        }
    }
}