Mathematical validators for prime numbers, factorials, GCD, and numeric type checking.
25 code snippets available
Efficiently checks if a number is prime.
Checks if a number is even.
Checks if a number is odd.
Bitwise check if number is a power of 2.
Euclidean algorithm for GCD.
Restricts a number within a min and max range.
Generates a random integer between min and max (inclusive).
Calculates n! (recursive).
Returns nth Fibonacci number.
Checks if number is positive.
Checks if number is negative.
Checks if number is an integer.
Checks if number has decimal places.
Generates array of numbers in range.
Calculates sum of array numbers.
Calculates average of array numbers.
Calculates median of array numbers.
0-100 with optional decimal.
e.g. 1.23e-4
Valid Roman numeral.
Positive whole number.
Negative whole number.
Number with decimals.
Binary representation.
Octal representation.
Our math & logic validation snippets are designed to handle the most common validation scenarios you'll encounter in modern software development. Each snippet is thoroughly tested, optimized for performance, and follows industry best practices.
All validators are available in multiple programming languages including JavaScript, TypeScript, Python, Go, PHP, C#, and Rust. Simply copy the code snippet, adapt it to your specific needs, and integrate it into your project. Every snippet is MIT licensed—free for personal and commercial use.