2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
13
Task/Digital-root/R/digital-root.r
Normal file
13
Task/Digital-root/R/digital-root.r
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
y=1
|
||||
digital_root=function(n){
|
||||
x=sum(as.numeric(unlist(strsplit(as.character(n),""))))
|
||||
if(x<10){
|
||||
k=x
|
||||
}else{
|
||||
y=y+1
|
||||
assign("y",y,envir = globalenv())
|
||||
k=digital_root(x)
|
||||
}
|
||||
return(k)
|
||||
}
|
||||
print("Given number has additive persistence",y)
|
||||
Loading…
Add table
Add a link
Reference in a new issue