Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 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