A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Factorial in Objective C page! Here, you'll find the source code for this program as well as a description of how the program works.
//
// main.m
// Factorial in ObjC
//
#import <Foundation/Foundation.h>
int fac(int n) {
if (n > 1) {
return fac(n -1) * n;
}
else {
return 1;
}
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
int input;
NSLog (@"Enter a number: ");
scanf("%d", &input);
int result = fac(input);
NSLog (@"\n %d", result);
}
return 0;
}
Factorial in Objective C was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.