Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/Semiprime/Sidef/semiprime-1.sidef
Normal file
2
Task/Semiprime/Sidef/semiprime-1.sidef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
say is_semiprime(2**128 + 1) #=> true
|
||||
say is_semiprime(2**256 - 1) #=> false
|
||||
11
Task/Semiprime/Sidef/semiprime-2.sidef
Normal file
11
Task/Semiprime/Sidef/semiprime-2.sidef
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
func is_semiprime(n, B=1e4) {
|
||||
|
||||
with (n.trial_factor(B)) { |f|
|
||||
return false if (f.len > 2)
|
||||
return f.all { .is_prime } if (f.len == 2)
|
||||
}
|
||||
|
||||
n.factor.len == 2
|
||||
}
|
||||
|
||||
say [2,4,99,100,1679,32768,1234567,9876543,900660121].grep(is_semiprime)
|
||||
Loading…
Add table
Add a link
Reference in a new issue