Eli - 11 months ago 73

C# Question

Was wondering how is it possible to generate 512 bit (155 decimal digits) prime number, last five decimal digits of which are specified/fixed (eg. ***28071) ??

The principles of generating simple primes without any specifications are quite understandable, but my case goes further.

Any hints for, at least, where should I start?

Java or C# is preferable.

Thanks!

Answer Source

I guess the only way would be to first generate a random number of 150 decimal digits, then append the 28071 behind it by doing `number = randomnumber * 100000 + 28071`

then just brute force it out with something like

```
while (!IsPrime(number))
number += 100000;
```

Of course this could take awhile to compute ;-)