+ 2
Script question
Does anyone have ideas on how to write a python script that finds and prints out prime numbers that reach 1 billion ??? Also these have to be within an array as well. i have a relevent idea but i cant seem to get primes that high of a number.
4 Antworten
+ 3
Well first of all you have to create a program which finds prime numbers.
then you must insert each prime to an array. that's a pretty simple test.
The thing is that finding such large numbers are difficult to computers since they have to do many calculations.
My code for that is this:
----------------------------------------------------------------------------------------------
primes =[1,3,5]
num = int(input("Enter last number of range "))
def FindPrimes(n):
for x in range(1,n,2):
for i in range(3,int(x/2)+1,2):
if(x%i==0):
break
if(i>=int(x/2)-1):
primes.append(x)
break
def printArr(arr):
for x in range(len(arr)-1):
print(arr[x],end=" ,")
print(arr[len(arr)-1])
print("Prime numbers are:")
FindPrimes(num)
printArr(primes)
+ 3
You can define the last number of the range. the greater number you enter the more numbers you'll find
0
This is finding the largest set of prime numbers ????
0
Anthony Perez It seems your question appears to be an assignment. Please show us your attempt and use the 8 rules to get help from the community.
https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community
*can be a code coach solution which is meant for you to do to help you establish your skills abilities and where you need to learn... not the community
*one issued by a school or other institution
*one issued or created by another platform
*one that appears to be in the form of a challenge that was created by you or somewhere else.
Your question will be reviewed by a team of moderators and will most likely be marked for deletion.
https://www.sololearn.com/Discuss/1316935/?ref=app