Function isPrime(number)
checks whether provided number is prime or not.
Function getPrimes(start, finish)
generates prime numbers sequence in provided range. Range can be provided in wrong sequence, i.e. getPrimes(20,0)
.
Function primeFactorsDecomposition(n)
decomposes provided integer to prime factors and return output in format "(p1**n1)(p2**n2)...(pk**nk)"
.
Class Primes
has static methods: isPrime(n)
- checks if n
is a prime number, first(n)
- returns first n
prime numbers. The class memorises previously generated primes in static variable primes
.
Function primesBeforeAndAfter(num)
returns an array of primes [primeBefore, primeAfter]
before and after the provided number num
.
Function findPrimesInString(str)
finds primes in a string if str
contains a substring prime
(not case sensitive), or if str
contains prime numbers apart from letters. The function uses recursion instead of loops.
Scripts by V.