Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Declaring a simple recursive function

CodingUnit edited this pageNov 30, 2011 ·2 revisions

Declaring a simple recursive function

  • Category: Recursion

  • Description: Declaring a simple recursive function

  • Code:

def SampleRec1() {def fib(n) {if (n <2)1else fib(n-1)+ fib(n-2) }foreach (iin $[0..10])WriteLine($"fib$i= {0}", fib(i))}SampleRec1()

Execution Result:

 fib1 =1 fib2 =2 fib3 =3 fib4 =5 fib5 =8 fib6 =13 fib7 =21 fib8 =34 fib9 =55 fib10 =89

[Copyright ©](Terms of use, legal notice)

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp