void setup() {
Serial.begin(9600); // Start serial communication
}
void loop() {
int result[200]; // Array to store the digits of the factorial
int n = 100; // Calculate the factorial of 100
int length = 1; // Current length of the factorial
// Initialize the array with 1 digit
result[0] = 1;
// Multiply the factorial by each number from 2 to n
for (int i = 2; i <= n; i++) {
int carry = 0; // Carry from the previous multiplication
// Multiply each digit of the factorial by i and add the carry
for (int j = 0; j < length; j++) {
int digit = result[j] * i + carry;
result[j] = digit % 10;
carry = digit / 10;
}
// Add the remaining carry to the factorial
while (carry != 0) {
result[length] = carry % 10;
carry /= 10;
length++;
}
}
// Print the result to the serial monitor
for (int i = length - 1; i >= 0; i--) {
Serial.print(result[i]);
}
Serial.println();
while(1); // Stop the program
}