![]() |
|
|
#1 |
|
Sep 2009
22×32 Posts |
Dear All,
I need to calculate X = (p-1/ 2q ) mod p where p and q are primes. Is there a better way than doing modular division? |
|
|
|
|
|
#2 |
|
Jan 2005
Caught in a sieve
5×79 Posts |
Edit: No, I don't think I know of a better way, except that you can simplify (P-1) mod P.
Is this homework?
Last fiddled with by Ken_g6 on 2010-10-11 at 14:18 |
|
|
|
|
|
#3 |
|
Sep 2009
22·32 Posts |
It's not homework,
I need to write a program that repeatedly calculates X = (p-1/ 2q ) mod p where p and q are primes and list the results starting from p=3 to q. Instead of calling the Modular division subroutine every time I have a new prime p, I would prefer to have a faster way. In this case better means faster and simpler. Thanks |
|
|
|
|
|
#4 | ||
|
Nov 2003
22×5×373 Posts |
Quote:
There is a faster way if p is fixed and q varies. Quote:
If p is LARGE, I would recommend using a binary Extended Euclidean Algorithm, rather than a classical one. If p is VERY LARGE, I would use an FFT approach. How big are p and q? Last fiddled with by R.D. Silverman on 2010-10-11 at 15:02 |
||
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Primorial calculation | FreakyPotato | Programming | 7 | 2015-02-06 10:33 |
| GHZ-days calculation Q | tcharron | PrimeNet | 4 | 2014-06-27 23:27 |
| P-1 probability calculation | James Heinrich | PrimeNet | 33 | 2011-01-23 16:40 |
| CPU Credit Calculation | storm5510 | Software | 8 | 2009-09-25 21:06 |
| MMO Property Calculation | Bundu | Puzzles | 22 | 2009-09-22 01:30 |