To create an array with first ten primes in reverse in Python, you can use the following code:
main.py478 chars25 lines
This code defines a function is_prime
that checks if a number is prime or not. It then creates an empty list primes
and loops through the numbers from 2 until we have found 10 primes. When a prime is found, it is added to the primes
list. Finally, the list is reversed and printed.
The output of this code will be:
main.py37 chars2 lines
gistlibby LogSnag