Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
13
Task/Magic-constant/R/magic-constant.r
Normal file
13
Task/Magic-constant/R/magic-constant.r
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#This is equivalent to n*(n^2+1)/2, but it's easier to see where this form comes from
|
||||
magic <- function(n) sum(1:(n^2))/n
|
||||
|
||||
sapply(3:22, magic)
|
||||
magic(1003)
|
||||
|
||||
inv_magic <- function(lower){
|
||||
n <- 3
|
||||
while(magic(n)<=lower) n <- n+1
|
||||
return(n)
|
||||
}
|
||||
|
||||
sapply(cumprod(rep(10, 20)), inv_magic)
|
||||
Loading…
Add table
Add a link
Reference in a new issue