Skip to content

Commit

Permalink
update example1
Browse files Browse the repository at this point in the history
  • Loading branch information
Double-oxygeN committed Oct 13, 2020
1 parent 84a104d commit de8faec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/example1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from strutils import join
from sequtils import toSeq
import primality, primality/random

proc echoPrimality(n: int) =
Expand All @@ -20,17 +22,16 @@ proc echoPrimality(n: int) =

elif n.isComposite:
echo n, " is a composite number"
echo n, " = ", primeFactorization(n).join(" * ")

randomize()

let
x1 = genRandomPrime(100..150)
x2 = genRandomPrime(100..150)
x1 = genRandomPrime(10_000..60_000)
x2 = genRandomPrime(10_000..60_000)

echoPrimality x1
echoPrimality x2
echoPrimality x1 * x2

echo "Primes between ", min(x1, x2), " and ", max(x1, x2)
for p in primes(min(x1, x2)..max(x1, x2)):
echo p
echo "There are ", toSeq(primes(min(x1, x2)..max(x1, x2))).len, " primes between ", min(x1, x2), " and ", max(x1, x2)

0 comments on commit de8faec

Please sign in to comment.