Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
object HofstadterFigFigSeq extends App {
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
val r = ListBuffer(0, 1)
|
||||
val s = ListBuffer(0, 2)
|
||||
|
||||
def ffr(n: Int): Int = {
|
||||
val ffri: Int => Unit = i => {
|
||||
val nrk = r.size - 1
|
||||
val rNext = r(nrk)+s(nrk)
|
||||
r += rNext
|
||||
(r(nrk)+2 to rNext-1).foreach{s += _}
|
||||
s += rNext+1
|
||||
}
|
||||
|
||||
(r.size to n).foreach(ffri(_))
|
||||
r(n)
|
||||
}
|
||||
|
||||
def ffs(n:Int): Int = {
|
||||
while (s.size <= n) ffr(r.size)
|
||||
s(n)
|
||||
}
|
||||
|
||||
(1 to 10).map(i=>(i,ffr(i))).foreach(t=>println("r("+t._1+"): "+t._2))
|
||||
println((1 to 1000).toList.filterNot(((1 to 40).map(ffr(_))++(1 to 960).map(ffs(_))).contains)==List())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue