Category : primes

This is a code I have with me. I want to know what’s the significance of "y" in the code? `x = 125 y = 0 for i in range(1, x + 1): if x % i == 0: y = y + 1 if y == 2: print(x, "is prime number") else: print(x, "is ..

I have this piece of code for finding prime numbers under a specific limit, when using a big limit I get a segmentation fault, I’ve tried making the variables as high as I can but I still get it, I’m starting to think it has something to do with the array, any ideas? Code Source: ..

I’m new to programming and I have to display all the prime numbers that are the product of this code in rows of five. After too many hours of trying to find something online, this is what I came up with. This way, not even the prime numbers are being displayed in the end; only ..

Hey guys any help would be appreciated: Doing a Code wars problem to find a prime number given an integer value. It seems my program is working properly but for some reason, it fails the prime number test. There seem to be some outlier numbers that cause it to fail but I can’t find it ..

I know that the widely known code for prime numbers has to do with: bool checkPrime(int n) { bool prime = true; for (int i = 2; i < n; i++) { if ((n%i) == 0) { prime = false; } } return prime; } But is this ok if your looking for prime numbers: ..

I was trying to implement a large prime number generator, and the average time it takes to generate a 2048 bit lenght prime number is about 40s. I see from the analysis of call stack that the majority of the time (99%) was taken by modular multiplication, and performance changes very much changing this algorithm. ..

I’m trying to generate random prime numbers for an rsa assignment. I thought about filling an array with prime numbers and then generating a random from the index number (hope that makes sense). But i’m kind of lost on how to actually fill the array 🙁 This is what i have so far int arreglo[25]; ..