I am python beginner.
I want to get the multiplication of two prime numbers of the N digits I have entered in python.
I even implemented two prime numbers and multiplying them.
For example, if I enter 2, the multiplication of the 2-digit prime number should be output.(If you enter 2, it consists of the product of two prime numbers, such as 3 * 11 or 5 * 2 and etc. The result of the product is two digits.
If you enter 3, it consists of the product of two prime numbers, 97 * 5 or 83 * 7 and etc. Here, the result of the product is three digits.)
And only one result of multiplication should be output at random.
I don't know what to do next.
My code is
import random
nums = []
for num in range(10,100):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
break
else:
nums.append(num)
prime = random.sample(nums, 2)
print(prime)
N = prime[0] * prime[1]
print('multiply with the two prime numbers:', N)
And 'range' is a randomly set range in "for num in range(10,100)"
for num in range(10,100)"
Aucun commentaire:
Enregistrer un commentaire