Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
46
Task/Fusc-sequence/Dyalect/fusc-sequence.dyalect
Normal file
46
Task/Fusc-sequence/Dyalect/fusc-sequence.dyalect
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
let n = 61
|
||||
let l = [0, 1]
|
||||
|
||||
func fusc(n) {
|
||||
return l[n] when n < l.Length()
|
||||
let f = (n &&& 1) == 0 ? l[n >>> 1] : l[(n - 1) >>> 1] + l[(n + 1) >>> 1]
|
||||
l.Add(f)
|
||||
return f
|
||||
}
|
||||
|
||||
var lst = true
|
||||
var w = -1
|
||||
var c = 0
|
||||
var t = nil
|
||||
var res = ""
|
||||
|
||||
print("First \(n) numbers in the fusc sequence:")
|
||||
for i in 0..Integer.Max {
|
||||
let f = fusc(i)
|
||||
if lst {
|
||||
if i < 61 {
|
||||
print("\(f) ", terminator: "")
|
||||
} else {
|
||||
lst = false
|
||||
print("")
|
||||
print("Points in the sequence where an item has more digits than any previous items:")
|
||||
print("Index/Value:")
|
||||
print(res)
|
||||
res = ""
|
||||
}
|
||||
}
|
||||
t = f.ToString().Length()
|
||||
if t > w {
|
||||
w = t
|
||||
res += (res == "" ? "" : "\n") + "\(i)/\(f)"
|
||||
if !lst {
|
||||
print(res)
|
||||
res = ""
|
||||
}
|
||||
c += 1
|
||||
if c > 5 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
l.Clear()
|
||||
Loading…
Add table
Add a link
Reference in a new issue