Shreenil.com Spirituality what is the program for product of first 10 prime numbers

what is the program for product of first 10 prime numbers

To find the product of the first 10 prime numbers, you can write a program in any programming language. Here’s an example program in Python:

python
Copy code
# Define a function to check if a number is prime
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True

# Initialize variables
product = 1
count = 0
num = 2

# Loop through the first 10 prime numbers
while count < 10:
if is_prime(num):
product *= num
count += 1
num += 1

# Print the product of the first 10 prime numbers
print(product)
This program defines a function is_prime(n) to check if a number is prime, and then initializes variables product, count, and num. The program then loops through the first 10 prime numbers, multiplying each prime number by the previous ones to calculate the product. Finally, it prints the product of the first 10 prime numbers, which is 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 = 6469693230.


There is no ads to display, Please add some

Related Post