- #1
Smidgen
- 3
- 0
I've created a simple algorithm to count primes up to say 1000 which satisfies a certain criterion :
count = 0;
Do[p = Prime[jj];
If[And[MultiplicativeOrder[2, p] == p - 1,
MultiplicativeOrder[3, p] == p - 1], count = count + 1], {jj, 3, 1000}]
count
Now this algorithm works... but I'm interested in the percentage of primes (here, out of 1000) that satisfies the criterion. My algorithm only counts the primes but does not divide the number of primes counted by the number of primes. I would like to create a function where I can input any x ( the number of primes), and the function will spit out the percentage that I'm interested in. But I'm having a problem with this function ( particularly with Return[] ) that I'm testing:
func23[x_] :=
[
count = 0;
Do[p = Prime[jj];
If[And[MultiplicativeOrder[2, p] == p - 1,
MultiplicativeOrder[3, p] == p - 1], count = count + 1], {jj, 3,
x}];
Return[count/(x - 2)]
]
Any insights or suggestions would be greatly appreciated :)
count = 0;
Do[p = Prime[jj];
If[And[MultiplicativeOrder[2, p] == p - 1,
MultiplicativeOrder[3, p] == p - 1], count = count + 1], {jj, 3, 1000}]
count
Now this algorithm works... but I'm interested in the percentage of primes (here, out of 1000) that satisfies the criterion. My algorithm only counts the primes but does not divide the number of primes counted by the number of primes. I would like to create a function where I can input any x ( the number of primes), and the function will spit out the percentage that I'm interested in. But I'm having a problem with this function ( particularly with Return[] ) that I'm testing:
func23[x_] :=
[
count = 0;
Do[p = Prime[jj];
If[And[MultiplicativeOrder[2, p] == p - 1,
MultiplicativeOrder[3, p] == p - 1], count = count + 1], {jj, 3,
x}];
Return[count/(x - 2)]
]
Any insights or suggestions would be greatly appreciated :)