Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //facilitating iteration with goto statement.
- int factorial(int i)
- {
- int total = 1;
- fact_step:
- if(!i) goto end;
- else {
- total *= i--;
- goto fact_step;
- }
- end:
- return total;
- }
- int main(void) {
- printf("The factorial of 3 is %d\n", factorial(3));
- return 0;
- }
Add Comment
Please, Sign In to add comment