Skip to content

Instantly share code, notes, and snippets.

@SirmaXX
Last active June 26, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirmaXX/54684d705ab524ea8dd71b7426e9523b to your computer and use it in GitHub Desktop.
Save SirmaXX/54684d705ab524ea8dd71b7426e9523b to your computer and use it in GitHub Desktop.
Mae for two loop
startTime <- Sys.time()
y<-c(10,8,6,4,2)
x<-c(5,4,3,2,1)
n<-length(y)
toplam=0
for (i in 1:n) {
diff=y[i]-x[i]
toplam=toplam+diff
}
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
# for (i in 1:n) {
# diff=y[i]-x[i]
# toplam=toplam+diff
# }
#
# sonuc=toplam/n
# print(sonuc)
#[1] 3
#
# endTime <- Sys.time()
#
# print(endTime-startTime )
#Time difference of 0.008654833 secs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment