Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Fusc-sequence/R/fusc-sequence-1.r
Normal file
15
Task/Fusc-sequence/R/fusc-sequence-1.r
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
firstNFuscNumbers <- function(n)
|
||||
{
|
||||
stopifnot(n > 0)
|
||||
if(n == 1) return(0) else fusc <- c(0, 1)
|
||||
if(n > 2)
|
||||
{
|
||||
for(i in seq(from = 3, to = n, by = 1))
|
||||
{
|
||||
fusc[i] <- if(i %% 2) fusc[(i + 1) / 2] else fusc[i / 2] + fusc[(i + 2) / 2]
|
||||
}
|
||||
}
|
||||
fusc
|
||||
}
|
||||
first61 <- firstNFuscNumbers(61)
|
||||
cat("The first 61 Fusc numbers are:", "\n", first61, "\n")
|
||||
4
Task/Fusc-sequence/R/fusc-sequence-2.r
Normal file
4
Task/Fusc-sequence/R/fusc-sequence-2.r
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
index <- which.max(nchar(first61) == 2)
|
||||
number <- first61[index]
|
||||
cat("The first fusc number that is longer than all previous fusc numbers is", number,
|
||||
"and it occurs at index", index, "\n")
|
||||
7
Task/Fusc-sequence/R/fusc-sequence-3.r
Normal file
7
Task/Fusc-sequence/R/fusc-sequence-3.r
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
twentyMillion <- firstNFuscNumbers(2 * 10^7)
|
||||
twentyMillionCountable <- format(twentyMillion, scientific = FALSE, trim = TRUE)
|
||||
indices <- sapply(2:6, function(x) which.max(nchar(twentyMillionCountable) == x))
|
||||
numbers <- twentyMillion[indices]
|
||||
cat("Some fusc numbers that are longer than all previous fusc numbers are:\n",
|
||||
paste0(format(twentyMillion[indices], scientific = FALSE, trim = TRUE, big.mark = ","),
|
||||
" (at index ", format(indices, trim = TRUE, big.mark = ","), ")\n"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue