# 程式設計(0411)
## 班級 學號 姓名
### 內建函數
請參考網站 [cplusplus](https://cplusplus.com/reference/)
### 自定函數

前置
```c=
#include <stdio.h>
int function add_sum(int n){
int sum = 0;
for (int i = 1; i <= n; i++){
sum += i;
}
return sum;
}
int main(){
printf("%d\n", add_sum(10));
printf("%d\n", add_sum(100));
return 0;
}
```
後置
```c=
#include <stdio.h>
int function add_sum(int); // prototype
int main(){
printf("%d\n", add_sum(10));
printf("%d\n", add_sum(100));
return 0;
}
int function add_sum(int n){
int sum = 0;
for (int i = 1; i <= n; i++){
sum += i;
}
return sum;
}
```
### 遞迴函數
1. 輸入正整數$n$,求$n!$。
$$n!=n\times (n-1)\times \cdots \times 2\times 1$$
2. 輸入正整數$n$,求Fabaincci數列的第$n$項。
$$F(n)=
\begin{cases}
1 & ,if\ n=1 \ or\ n=2 \\
F(n-2)+F(n-1) & ,if\ n\geq 3
\end{cases}
$$
3. 輸入正整數$a,b$,求其最大公因數。
$$gcd(a,b)=
\begin{cases}
b & , if\ a\% b=0 \\
gcd(b,r) & ,otherwise\ r = a \% b
\end{cases}
$$
4. 輸入正整數$m,n$,求組合數$C^m_n$。
$$C^m_n=
\begin{cases}
1 & ,if\ n=0 \ or\ m=n \\
C^{m-1}_n+C^{m-1}_{n-1} & ,otherwise
\end{cases}
$$
---
作業繳交方式:寄E-mail
收件人:lenghs@cc.ncue.edu.tw
主旨:程式設計(0411)
附件:程式設計(0411) - HackMD.pdf
內文:本日上課心得(字數不限不得省略)