Find the nth prime number using primality testing.
Code
Algorithmspython3 -c "
def is_prime(x):
if x < 2: return False
for i in range(2, int(x**0.5) + 1):
if x % i == 0: return False
return True
count, num = 0, 1
while count < $n:
num += 1
if is_prime(num): count += 1
print(num)
"Parameters
Position (1-indexed)
Server
More Bash Snippets
Binary to Decimal
Convert a binary string representation to its decimal number equivalent.
Bytes to Human Readable
Convert bytes to human readable format (KB, MB, GB, etc.) for file sizes.
Calculate Median
Calculate the median value of an array of numbers.
Calculate Mode
Find the most frequent value(s) in an array.
Calculate Percentile
Calculate the nth percentile of an array using linear interpolation.
Celsius to Fahrenheit
Convert temperature from Celsius to Fahrenheit using the standard formula.