Math
31 snippets
Clamp
VerifiedRestricts a number to an inclusive minimum and maximum.
Binary to Unsigned Integer Conversion
Converts a binary number represented as a string to its decimal equivalent.
Calculate Compound Interest
Calculates compound interest for a given principal amount, rate, and time period.
Calculate Factorial
Computes the factorial of a given integer.
Check Perfect Number
Checks if a number is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself).
Check Perfect Square
Checks if a number is a perfect square.
Check Prime Number
Check if an integer is a prime number
Checksum
Calculates the checksum of an int
Combinations
Calculates the number of combinations (denoted as C(n,r) or "n choose r"), which determines how many ways you can select r items from n items without considering the order.
Compound Interest
Calculates the compound interest for a given principal, rate, time, and number of times interest applied per time period.
Convert Binary to Decimal
Converts a binary string to its decimal equivalent.
Convert Bytes to Human-Readable Format
Converts a size in bytes to a human-readable format.
Cross Product
Computes the cross product of two 3D vectors, which results in a vector perpendicular to both.
Dot Product
Computes the dot product of two vectors, which is the sum of the products of corresponding elements.
Error function
Computes the error function (erf(x)) for a given input x, which is a mathematical function used frequently in probability, statistics, and partial differential equations.
Factorial
Computes the factorial of a given number
Factorial Function
Calculates the factorial of a number.
Fibonacci
Calculates the nth fibonacci number
Fibonacci Number
Calculates the nth Fibonacci number using recursion.
Find all primes up to integer (Sieve of Sundaram)
Finds all the prime numbers up to a specific integer.
Find LCM (Least Common Multiple)
Calculates the least common multiple (LCM) of two numbers.
Greatest Common Divisor
Calculates the greatest common divisor (gcd) of two numbers
Least Common Multiple
Calculates the least common multiple (lcm) of two numbers
Linear Mapping
remaps a value from one range to another
Matrix Multiplication
Multiplies two matrices, where the number of columns in the first matrix equals the number of rows in the second.
Modular Inverse
Computes the modular multiplicative inverse of a number a under modulo m, which is the integer x such that (a*x) mod m=1.
Prime Check
Checks if a number is a prime
Prime Number
Checks if a number is a prime number or not.
Solve Quadratic Equation
Solves a quadratic equation ax^2 + bx + c = 0 and returns the roots.
Sum of Digits
Calculates the sum of the digits of an integer.
Swap numbers
Swaps two numbers without using third variable