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 ..

#### Category : primes

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]; ..

I would like your help to understand how the below code is producing the prime numbers. The code is correct, but I am not sure how isprime = trial % primes[3] > 0; is not a prime number as to my understanding for i= 3 it should be 9/7 which means there is a reminder ..

I am trying to figure out an effective way to solve the following problem: Print the first N prime numbers I only managed to work out a really slow solution: #include <iostream> int main(){ std::ios_base::sync_with_stdio(0); int n, counter = 1, aux, i = 2; std::cin >> n; while(counter <= n){ aux = 0; for (int ..

I need to implement public key cryptography for a digital signature for a custom program that I’m writing, and at the moment I’m trying to implement RSA in C++ (though I’m open to other algorithms as long as they’re good), but I’m not having trouble with the algorithm itself. Rather, I’m trying to figure out ..

## Recent Comments