This is a program to generate all prime numbers between 0 and a given number(y). Is it possible to "translate" this program to java? The assignment calls on me to do this in java and I see no need to reinvent the wheel.
#Function that determines whether a number is prime def Primality(n): if n < 2: return False for x in range (2, int(math.sqrt(n)) + 1): if n % x == 0: return False return True # variables to keep track of primes found and to advance the number tested primes = 0 # counts the number of prime numbers the program finds n = 1 # variable used by the program to count and run each number through the primality function y = 10000 # the limit for the counter. # while loop calls the primality function until "y" primes are found. It will also list the prime numbers found while primes < y: n += 1 Primality(n) if Primality(n): print( n ) primes += 1 print( "I have", primes ,"prime numbers" ) print( n, "is the nth prime number.")