#import <Foundation/Foundation.h>
float factorial(int n)
{
if(n<=1)
return(1);
return n*factorial(n-1);
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
long fact=factorial(8);
NSLog (@"Factorial of 8 is %ld",fact);
[pool drain];
return 0;
}
float factorial(int n)
{
if(n<=1)
return(1);
return n*factorial(n-1);
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
long fact=factorial(8);
NSLog (@"Factorial of 8 is %ld",fact);
[pool drain];
return 0;
}
No comments:
Post a Comment