Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
692 B
3
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <string.h>
#include <math.h>

int arr[3010] = {1};

void fact(int *arr, int number) {
	int num,idx;
	for (int i = 1; i <= number; i++)
	{
		for (int k = 0; k < 3010; k++)
		{
			if (arr[k] != 0)
			{
				arr[k] *= i;
				if (arr[k] > 9)
				{
					arr[k + 1] += arr[k] / 10;
					arr[k] = arr[k] % 10;
				}
			}
		}
	}
	for (int i = 3009; arr[i] == 0; i--)
	{
		idx = i;
	}
	for ( ;idx > 0; idx--)
	{
		printf("%d", arr[idx]);
	}
}

int main() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int number; 
	scanf("%d", &number);
	fact(arr, number);

	return 0;
}