Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Perfect-numbers/R/perfect-numbers.r
Normal file
11
Task/Perfect-numbers/R/perfect-numbers.r
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
is.perf <- function(n){
|
||||
if (n==0|n==1) return(FALSE)
|
||||
s <- seq (1,n-1)
|
||||
x <- n %% s
|
||||
m <- data.frame(s,x)
|
||||
out <- with(m, s[x==0])
|
||||
return(sum(out)==n)
|
||||
}
|
||||
# Usage - Warning High Memory Usage
|
||||
is.perf(28)
|
||||
sapply(c(6,28,496,8128,33550336),is.perf)
|
||||
Loading…
Add table
Add a link
Reference in a new issue