Last active
June 26, 2022 13:36
-
-
Save SirmaXX/7f054b0fdcaf882ea781d35492eb7471 to your computer and use it in GitHub Desktop.
mae for while
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
startTime <- Sys.time() | |
y<-c(10,8,6,4,2) | |
x<-c(5,4,3,2,1) | |
n<-length(y) | |
toplam=0 | |
i <- 1 | |
while (i <= n) { | |
diff=y[i]-x[i] | |
toplam=toplam+diff | |
i <- i + 1 | |
} | |
sonuc=toplam/n | |
print(sonuc) | |
endTime <- Sys.time() | |
print(endTime-startTime ) | |
#Output | |
#startTime <- Sys.time() | |
# | |
# y<-c(10,8,6,4,2) | |
# x<-c(5,4,3,2,1) | |
# n<-length(y) | |
# | |
# toplam=0 | |
# | |
# i <- 1 | |
# while (i <= n) { | |
# diff=y[i]-x[i] | |
# toplam=toplam+diff | |
# i <- i + 1 | |
# | |
# } | |
# | |
# | |
# sonuc=toplam/n | |
# print(sonuc) | |
#[1] 3 | |
# | |
# endTime <- Sys.time() | |
# | |
# print(endTime-startTime ) | |
#Time difference of 0.009809256 secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment