我很新的閃亮,但我想實現遞歸階乘功能轉換爲RFacfactorial功能
這裏是我想實現的代碼:
recursive.factorial <- function(x) {
# if the value of x is 0 or 1, then 1 is returned
if (x == 0 || x == 1) {
return (1)
}
else {
return (x * recursive.factorial(x - 1)) # recursive function to calculate the factorial
}
}
recursive.factorial(5)
它甚至有可能在Shiny中放置這樣的東西?
謝謝
FYI - 我只是想在sidepanel中輸入factorial函數,然後在mainPanel中返回結果。 – Nathan
當然有可能... – Roland