Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
27
Task/Yellowstone-sequence/Agena/yellowstone-sequence.agena
Normal file
27
Task/Yellowstone-sequence/Agena/yellowstone-sequence.agena
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
scope # Yellowstone sequence - translation of the Pluto sample
|
||||
|
||||
local procedure yellowstone( n :: number ) :: table
|
||||
local a, m := [ 1, 2, 3 ], [ true, true, true ];
|
||||
for x from 4 to n do
|
||||
a[ x ], m[ x ] := 0, false
|
||||
od;
|
||||
local minV := 4;
|
||||
for c from 4 to n do
|
||||
local more := true
|
||||
for i from minV while more do
|
||||
if not m[ i ] and numtheory.gcd( a[ c - 1 ], i ) = 1 and numtheory.gcd( a[ c - 2 ], i ) > 1
|
||||
then
|
||||
a[ c ], m[ i ] := i, true;
|
||||
if i = minV then minV +:= 1 fi;
|
||||
more := false
|
||||
fi
|
||||
od
|
||||
od;
|
||||
return a
|
||||
end;
|
||||
|
||||
local constant ySize, constant perLine := 30, 10;
|
||||
local y := yellowstone( ySize );
|
||||
printf( "The first %d Yellowstone numbers are:\n", ySize );
|
||||
for yPos to ySize do printf( " %2d", y[ yPos ] ); if yPos mod perLine = 0 then print() fi od
|
||||
end
|
||||
45
Task/Yellowstone-sequence/Fennel/yellowstone-sequence.fennel
Normal file
45
Task/Yellowstone-sequence/Fennel/yellowstone-sequence.fennel
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
(do ;;; Yellowstone sequence - translation of the Pluto sample
|
||||
|
||||
(fn gcd [m n]
|
||||
(var (a b) (values (math.abs m) (math.abs n)))
|
||||
(while (not= b 0)
|
||||
(set (b a) (values (% a b) b))
|
||||
)
|
||||
a
|
||||
)
|
||||
|
||||
(fn yellowstone [n]
|
||||
(var (a m) (values [1 2 3] [true true true]))
|
||||
(for [x 4 n]
|
||||
(tset a x 0)
|
||||
(tset m x false)
|
||||
)
|
||||
(var minV 4)
|
||||
(for [c 4 n]
|
||||
(var (more i) (values true minV))
|
||||
(while more
|
||||
(when (and (not (. m i))
|
||||
(= (gcd (. a (- c 1)) i) 1)
|
||||
(> (gcd (. a (- c 2)) i) 1)
|
||||
)
|
||||
(tset a c i)
|
||||
(tset m i true)
|
||||
(when (= i minV)
|
||||
(set minV (+ 1 minV))
|
||||
)
|
||||
(set more false)
|
||||
)
|
||||
(set i (+ i 1))
|
||||
)
|
||||
)
|
||||
a
|
||||
)
|
||||
|
||||
(local (ySize perLine) (values 30 10))
|
||||
(local y (yellowstone ySize))
|
||||
(io.write (string.format "The first %d Yellowstone numbers are:\n" ySize))
|
||||
(for [yPos 1 ySize]
|
||||
(io.write (string.format " %2d" (. y yPos)))
|
||||
(when (= 0 (% yPos perLine)) (print))
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
NSInteger local fn GCD( a as NSInteger, b as NSInteger )
|
||||
if ( a == 0 ) then return b
|
||||
return fn GCD( b % a, a )
|
||||
end fn = 0
|
||||
|
||||
void local fn CalcYellowstoneSequence( terms as int )
|
||||
CFMutableArrayRef sequence = fn MutableArrayWithObjects( @1, @2, @3, NULL )
|
||||
|
||||
for int n = 3 to terms - 1
|
||||
NSInteger prev1 = fn NumberIntegerValue( fn ArrayObjectAtIndex( sequence, n - 1 ) )
|
||||
NSInteger prev2 = fn NumberIntegerValue( fn ArrayObjectAtIndex( sequence, n - 2 ) )
|
||||
NSInteger candidate = 1
|
||||
|
||||
while (YES)
|
||||
if ( !fn ArrayContainsObject( sequence, @(candidate) ) && fn GCD( candidate, prev1 ) == 1 && fn GCD( candidate, prev2 ) > 1 )
|
||||
MutableArrayAddObject( sequence, @(candidate) )
|
||||
break
|
||||
end if
|
||||
candidate++
|
||||
wend
|
||||
next
|
||||
|
||||
NSLog( @"Yellowstone sequence up to %d terms:", terms )
|
||||
for CFNumberRef num in sequence
|
||||
NSLog( @"%@ \b", num )
|
||||
next
|
||||
end fn
|
||||
|
||||
fn CalcYellowstoneSequence( 30 )
|
||||
|
||||
HandleEvents
|
||||
32
Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto
Normal file
32
Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
require "table2"
|
||||
local int = require "int"
|
||||
local fmt = require "fmt"
|
||||
|
||||
local function yellowstone(n)
|
||||
local m = {}
|
||||
local a = table.rep(n, 0)
|
||||
for i = 1, 3 do
|
||||
a[i] = i
|
||||
m[i] = true
|
||||
end
|
||||
local min = 4
|
||||
for c = 4, n do
|
||||
local i = min
|
||||
while true do
|
||||
if !m[i] and int.gcd(a[c - 1], i) == 1 and int.gcd(a[c - 2], i) > 1 then
|
||||
a[c] = i
|
||||
m[i] = true
|
||||
if i == min then ++min end
|
||||
break
|
||||
end
|
||||
++i
|
||||
end
|
||||
end
|
||||
return a
|
||||
end
|
||||
|
||||
local x = {}
|
||||
for i = 1, 30 do x[i] = i end
|
||||
local y = yellowstone(30)
|
||||
print("The first 30 Yellowstone numbers are:")
|
||||
fmt.tprint("%2d ", y, 10)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
-- 25 Apr 2025
|
||||
-- 28 Jul 2025
|
||||
include Settings
|
||||
numeric digits 100
|
||||
arg xx
|
||||
|
|
@ -14,7 +14,7 @@ call Timer
|
|||
exit
|
||||
|
||||
GetYellow:
|
||||
procedure expose yell. work.
|
||||
procedure expose yell. work. Memo.
|
||||
arg xx
|
||||
say 'Get yellowstones...'
|
||||
yell. = 0; work. = 0; n = 0
|
||||
|
|
@ -50,7 +50,4 @@ end
|
|||
say
|
||||
return
|
||||
|
||||
include Sequences
|
||||
include Functions
|
||||
include Helper
|
||||
include Abend
|
||||
include Math
|
||||
|
|
|
|||
24
Task/Yellowstone-sequence/YAMLScript/yellowstone-sequence.ys
Normal file
24
Task/Yellowstone-sequence/YAMLScript/yellowstone-sequence.ys
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
!YS-v0
|
||||
|
||||
defn main(n=30):
|
||||
say: yellow(n)
|
||||
|
||||
defn yellow(n):
|
||||
a =: +[1 2 3]
|
||||
b =: (1 .. 3).zipmap([true]:cycle)
|
||||
i =: 4
|
||||
loop a a, b b, i i:
|
||||
if n > a.#:
|
||||
? if b.$i.! &&
|
||||
(i.gcd(a.$) == 1) &&
|
||||
(i.gcd(a:butlast.$) > 1)
|
||||
: recur:
|
||||
a.conj(i), b.assoc(i true), 5
|
||||
recur: a, b, i.++
|
||||
=>: a
|
||||
|
||||
defn gcd(a b):
|
||||
loop a a, b b:
|
||||
if b.?:
|
||||
recur b: a % b
|
||||
else: a
|
||||
Loading…
Add table
Add a link
Reference in a new issue