Finalizing loop warmup

This commit is contained in:
Noah L. Schrick 2022-11-10 00:38:50 -06:00
parent 15c29fa1ef
commit f72050a436
2 changed files with 28 additions and 1 deletions

View File

@ -47,5 +47,32 @@ h1n1.Bris.aa.sortedtable <-h1n1.Bris.aa.table[order(h1n1.Bris.aa.table)]
names(h1n1.Bris.aa.sortedtable)<-aaa(names(h1n1.Bris.aa.sortedtable))
dotchart(h1n1.Bris.aa.sortedtable)
paste(h1n1.Bris.aa.vec,collapse="",sep="")
#
#### Part B: Loop Recursion Warmup
calc.num.paths <- function(n,m){
path_matrix <- matrix(1, nrow=m+1, ncol=n+1)
for (i in seq(2,m+1)){
for (j in seq(2, n+1)){
path_matrix[i,j] <- path_matrix[i-1,j] + path_matrix[i,j-1]
}
}
path_matrix[m+1,n+1]
}
m <- 5 # row edges
n <- 5 # col edges
calc.num.paths(n,m)
factorial(n+m)/(factorial(n)*factorial(m))
m <- 5 # row edges
n <- 6 # col edges
calc.num.paths(n,m)
factorial(n+m)/(factorial(n)*factorial(m))
m <- 10 # row edges
n <- 10 # col edges
calc.num.paths(n,m)
factorial(n+m)/(factorial(n)*factorial(m))

Binary file not shown.