Advertisement
DigitalMag

searchPrimeDigits

Jul 5th, 2020
3,298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.42 KB | None | 0 0
  1.  
  2. import times
  3.  
  4. template `print`(a: any) = echo a
  5.  
  6. var a = @[1,2,3]
  7. for i in a:
  8.     echo i    
  9.  
  10. proc is_prime(n: int): bool =
  11.     if n<2: return false
  12.     var d = 2
  13.     while n mod d != 0:
  14.         d+=1
  15.     result = d == n
  16.  
  17.  
  18. var primes = newSeq[int](0)
  19. print 97999997-97999797
  20.  
  21. let t0 = epochTime()
  22.  
  23. for i in 97999797..97999997:
  24.     if is_prime(i):
  25.         primes.add(i)
  26.  
  27. echo epochTime() - t0
  28.  
  29. echo primes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement