2009/06/04

ブログ再開します!

一発目。自己末尾再帰関数。processingで。

void setup()
{
noLoop();
}

void draw()
{
int val=1;
println(factorial(val,4));

}

int factorial(int temp, int n){

if(temp>0)
temp*=n;
else
println("error");

if(n-1==0){
return temp;
}
else{
return factorial(temp, n-1);
}
}

コメントはありません

About Me

自分の写真
目指せネイチャアプログラマ!Objective-C/Cocoa、web系スキルも絶賛習得中。Nature Interfaceに興味ありあり。
Powered By Blogger

Mitolog © 2008. Template by Dicas Blogger.

TOPへ