tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,12 @@
|
|||
is_prime = (n) ->
|
||||
# simple prime detection using trial division, works
|
||||
# for all integers
|
||||
return false if n <= 1 # by definition
|
||||
p = 2
|
||||
while p * p <= n
|
||||
return false if n % p == 0
|
||||
p += 1
|
||||
true
|
||||
|
||||
for i in [-1..100]
|
||||
console.log i if is_prime i
|
||||
Loading…
Add table
Add a link
Reference in a new issue