diff options
author | Jeff Ames | 2009-06-09 18:07:35 +0000 |
---|---|---|
committer | Jeff Ames | 2009-06-09 18:07:35 +0000 |
commit | a7fcacf8f396acbca0b640a65acfbf5487d513e7 (patch) | |
tree | 5ba66f5c83eceeb81e24a0540ae4fac9847e0c78 /OpenSim/Framework/PrimeNumberHelper.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.zip opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.gz opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.bz2 opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.xz |
Formatting cleanup. Ignore some generated files.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/PrimeNumberHelper.cs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/OpenSim/Framework/PrimeNumberHelper.cs b/OpenSim/Framework/PrimeNumberHelper.cs index 589f87d..477c274 100644 --- a/OpenSim/Framework/PrimeNumberHelper.cs +++ b/OpenSim/Framework/PrimeNumberHelper.cs | |||
@@ -58,28 +58,28 @@ namespace OpenSim.Framework | |||
58 | /// <returns> | 58 | /// <returns> |
59 | /// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1. | 59 | /// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1. |
60 | /// </returns> | 60 | /// </returns> |
61 | public static int GetPrime( int min ) | 61 | public static int GetPrime(int min) |
62 | { | 62 | { |
63 | if( min <= 2 ) | 63 | if (min <= 2) |
64 | return 2; | 64 | return 2; |
65 | 65 | ||
66 | if( Primes[ Primes.Length - 1 ] < min ) | 66 | if (Primes[ Primes.Length - 1 ] < min) |
67 | { | 67 | { |
68 | for( int i = min | 1 ; i < 0x7FFFFFFF ; i += 2 ) | 68 | for (int i = min | 1 ; i < 0x7FFFFFFF ; i += 2) |
69 | { | 69 | { |
70 | if( IsPrime( i ) ) | 70 | if (IsPrime(i)) |
71 | return i; | 71 | return i; |
72 | } | 72 | } |
73 | 73 | ||
74 | return -1; | 74 | return -1; |
75 | } | 75 | } |
76 | 76 | ||
77 | for( int i = Primes.Length - 2 ; i >= 0 ; i-- ) | 77 | for (int i = Primes.Length - 2 ; i >= 0 ; i--) |
78 | { | 78 | { |
79 | if( min == Primes[ i ] ) | 79 | if (min == Primes[ i ]) |
80 | return min; | 80 | return min; |
81 | 81 | ||
82 | if( min > Primes[ i ] ) | 82 | if (min > Primes[ i ]) |
83 | return Primes[ i + 1 ]; | 83 | return Primes[ i + 1 ]; |
84 | } | 84 | } |
85 | 85 | ||
@@ -95,17 +95,17 @@ namespace OpenSim.Framework | |||
95 | /// <returns> | 95 | /// <returns> |
96 | /// true, if <see cref="candinate"/> is prime number; otherwise false. | 96 | /// true, if <see cref="candinate"/> is prime number; otherwise false. |
97 | /// </returns> | 97 | /// </returns> |
98 | public static bool IsPrime( int candinate ) | 98 | public static bool IsPrime(int candinate) |
99 | { | 99 | { |
100 | if( (candinate & 1) == 0 ) | 100 | if ((candinate & 1) == 0) |
101 | 101 | ||
102 | // Even number - only prime if 2 | 102 | // Even number - only prime if 2 |
103 | return candinate == 2; | 103 | return candinate == 2; |
104 | 104 | ||
105 | int upperBound = (int) Math.Sqrt( candinate ); | 105 | int upperBound = (int) Math.Sqrt(candinate); |
106 | for( int i = 3 ; i < upperBound ; i += 2 ) | 106 | for (int i = 3 ; i < upperBound ; i += 2) |
107 | { | 107 | { |
108 | if( candinate % i == 0 ) | 108 | if (candinate % i == 0) |
109 | return false; | 109 | return false; |
110 | } | 110 | } |
111 | 111 | ||