Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
50
Task/Pell-numbers/Unicon/pell-numbers.unicon
Normal file
50
Task/Pell-numbers/Unicon/pell-numbers.unicon
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
link fastprime
|
||||
|
||||
global pidx
|
||||
|
||||
procedure main(A)
|
||||
limit := \A[1] | 10
|
||||
write("Pell numbers:")
|
||||
every writes(" ",pell(0,1)\limit | "\n")
|
||||
|
||||
write("\nPell-Lucas numbers:")
|
||||
every writes(" ",pell(2,2)\limit | "\n")
|
||||
|
||||
write("\nRational approximations to sqrt(2):")
|
||||
@(cp := create pell(0,1))
|
||||
@(cl := create pell(2,2))
|
||||
cnt := 1
|
||||
while (cnt <= limit, cnt +:=1) do
|
||||
(n := @cl/2, d := @cp, write(" (",n,"/",d,") = ",real(n)/d))
|
||||
|
||||
write("\n(Pell Prime Index,Pell Prime):")
|
||||
every p := is_prime(pell(0,1))\limit do write(" (",pidx,",",p,")")
|
||||
|
||||
write("\nNSW numbers:")
|
||||
every writes(" ",nsw()\limit | "\n")
|
||||
|
||||
write("\nTriangles:")
|
||||
every write(" ",triangles()\limit)
|
||||
end
|
||||
|
||||
procedure pell(p0,p1)
|
||||
pidx := -1
|
||||
repeat suspend 1(p := 2*p1 + p0, p :=: p1 :=: p0, pidx +:= 1)
|
||||
end
|
||||
|
||||
procedure nsw()
|
||||
ps := []
|
||||
n := 0
|
||||
every put(ps,pell(0,1)) do
|
||||
if *ps >= 2 then suspend 1(ps[2*n+1]+ps[2*n+2], n +:= 1)
|
||||
end
|
||||
|
||||
procedure triangles()
|
||||
n := 3
|
||||
repeat {
|
||||
(sum := 0, ps := [0])
|
||||
every put(ps,pell(0,1))\(n+1) do sum +:= ps[*ps-1]
|
||||
suspend (n%2 = 1, "("||sum||","||(sum+1)||","||ps[*ps]||")")
|
||||
n +:= 1
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue