Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define until(x) while(!(x))
- #define unless(x) if(!(x))
- unsigned int factorial(unsigned int n) {
- unsigned int fact=1, i;
- until ( n==0 )
- fact *= n--;
- return fact;
- }
- int main(int argc, char*argv[]) {
- unless (argc==2)
- puts("Usage: fact <num>");
- else {
- int n = atoi(argv[1]);
- if (n<0)
- puts("please give +ve number");
- else
- printf("factorial(%u) = %u\n",n,factorial(n));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement