Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Euclid-Mullin-sequence/Jq/euclid-mullin-sequence.jq
Normal file
16
Task/Euclid-Mullin-sequence/Jq/euclid-mullin-sequence.jq
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Output: the Euclid-Mullins sequence, beginning with 2
|
||||
def euclid_mullins:
|
||||
foreach range(1; infinite|floor) as $i ( { product: 1 };
|
||||
.next = .product + 1
|
||||
# find the first prime factor of .next
|
||||
| .p = 3
|
||||
| .found = false
|
||||
| until( .p * .p > .next or .found;
|
||||
.found = ((.next % .p) == 0)
|
||||
| if .found then . else .p += 2 end)
|
||||
| if .found then .next = .p else . end
|
||||
| .product *= .next)
|
||||
| .next ;
|
||||
|
||||
# Produce 16 terms
|
||||
limit(16; euclid_mullins)
|
||||
Loading…
Add table
Add a link
Reference in a new issue