(Python) def isprime(n): """ Input: n must be an int type. Output: True if n is prime, False otherwise. """ ct=0 if n==2: return True elif n==3: return True else: for x in range(2, int(n**(1/2)+1)): if n%x==0: return False break elif x==int(n**(1/2)): return True else: continue def det(l): n=len(l) if (n>2): i=1 t=0 sum=0 while t<=n-1: d={} t1=1 while t1<=n-1: m=0 d[t1]=[] while m<=n-1: if (m==t): u=0 else: d[t1].append(l[t1][m]) m+=1 t1+=1 l1=[d[x] for x in d] sum=sum+i*(l[0][t])*(det(l1)) i=i*(-1) t+=1 return sum else: return (l[0][0]*l[1][1]-l[0][1]*l[1][0]) ans="" while ans!="N": from math import log n=eval(input("Enter n for n X n matrix: ")) pList=[] for x in range(3, ((n-1)*(n+1)**3)): if isprime(x): pList.append(x) matrixList=[] addList=[2*k for k in range(1, n+1)] for num in addList: tmpList=[] for prime in pList: tmp=prime+num if tmp in pList: tmpList.append(prime) matrixList.append(tmpList) newMatrix=[matrixList[k][:n] for k in range(len(matrixList))] print() print("The determinant is: ", det(newMatrix)) print() ans=input("Continue (Y/N): ")