Factorial

Groophy.Math.Math.Factorial("4");
4*3*2*1 -> 24

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
        /// <summary>
        /// https://groophy-inc.github.io/factorial
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static GValue Factorial(GValue val)
        {
            IEnumerable<int> ints = Enumerable.Range(1, val.get_Int);
            return new GValue(ints.Aggregate((f, s) => f * s).ToString());
        }

Contact Us

Copyright © Groophy.Inc ' Batch-Man