Skip to main content

Numeric

๐Ÿ“˜ Numeric Extensionsโ€‹

Factorial

int result = 5.Factorial(); // 120

Root Finding (Newtonโ€“Raphson) โ€” xn+1=xnโˆ’f(xn)fโ€ฒ(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}

Func<double, double> func = x => Math.Pow(x, 2) - 4;
double root = func.NewtonRaphson(); // 2

๐Ÿ”ข Number Theoryโ€‹

bool prime = 79.IsPrime();                  // true
int[] factors = 78.GetPrimeFactors(); // [2, 3, 13]
bool happy = 19.IsHappy(); // true
bool perfect = 6.IsPerfectNumber(); // true
int decimals = 0.01.GetDecimalPlaces(); // 2

๐Ÿ“ Trigonometryโ€‹

double rad = 180.0.DegreeToRadians(); // ฯ€