-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
有了遞迴與決策能力,音界咒已經能計算不少東西了。試寫了幾個有代表性又常見的術。 | ||
|
||
## 輾轉相除法 | ||
|
||
```音界 | ||
術.輾轉相除(甲、乙)【 | ||
若(乙==0)【 | ||
歸.甲 | ||
】 | ||
歸.輾轉相除(乙、甲%乙) | ||
】 | ||
``` | ||
|
||
## 冪次 | ||
|
||
```冪次 | ||
術.冪(數、次方)【 | ||
若(次方==0)【 | ||
歸.1 | ||
】 | ||
歸.數*冪(數、次方-1) | ||
】 | ||
``` | ||
|
||
## 印出費氏數列前十項 | ||
|
||
```音界 | ||
術.費氏數(項)【 | ||
若(項<=1)【 | ||
歸.1 | ||
】 | ||
歸.費氏數(項-2)+費氏數(項-1) | ||
】 | ||
術.打印數列(項)【 | ||
若(項>1)【 | ||
打印數列(項-1) | ||
】 | ||
曰(費氏數(項)) | ||
】 | ||
術.初()【 | ||
打印數列(10) | ||
歸.0 | ||
】 | ||
``` | ||
|
||
## 更多範例 | ||
更多範例可以參考[音界咒範例幕目錄](https://github.com/MROS/yinjie-lang/tree/611271b2b935f41c720f12191d1432da5d6b4e9d/%E9%9B%B6%E8%99%9F%E7%B7%A8%E8%AD%AF%E5%99%A8/%E7%AF%84%E4%BE%8B)。 |