29.3k views
5 votes
Consider the following sequence, defined from n=2 to 15 (inclusive). Pn=n2−1. Produce a list named primes which only contains values from this sequence which are prime. We provide a function is_prime to assist you with this. Call it like this: is_prime( 5 ).

1 Answer

1 vote

Answer:

primes = []

for n in range(2,16):

pn = n*n - 1

if is_prime(pn):

primes.append(pn)