Jan-15-2022, 10:57 PM
I think i got it.
Thanks for pointing in the right direction. I need to focus on how to make good use of return.
lim = int(input("Generate prime numbers up to what number? : ")) def prime_eratosthenes(lim): prime_list = [] list = [] for i in range(2, lim+1): if i not in prime_list: print (i, end = ' ') list.append(i) for j in range(i*i, lim+1, i): prime_list.append(j) # print(j) return list def printPairs(lim): primes = prime_eratosthenes(lim) for i in range(0, len(primes)): for j in range(i+1, len(primes)): if (primes[i]*primes[j])==lim: print(' ') print(primes[i], primes[j]) printPairs(lim)
Output:Generate prime numbers up to what number? : 10
2 3 5 7
2 5
All prime under 10 with the pairs that = 10. (2 , 5)Thanks for pointing in the right direction. I need to focus on how to make good use of return.