Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save outlinepix/ebbb7db704cbdbf069fc9b09789565ad to your computer and use it in GitHub Desktop.
Save outlinepix/ebbb7db704cbdbf069fc9b09789565ad to your computer and use it in GitHub Desktop.
Large Factorials (code wars) in C language.
include<stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[])
{
factorial(5);
return 0;
}
char *factorial(int n)
{
if (n < 0)
{
return "";
}
unsigned long long int fact = 1;
for (int i = 1; i <= n; i++)
{
fact *= i;
}
char *result = malloc(sizeof(char) * 100);
sprintf(result, "%llu", fact);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment