# Factorial 8

Finds the factorial of the number 8 using recursion. The number 8 was chosen as its factorial is the largest number that will fit in 2 bytes - for easy reading in the memory panel.

## Processor: ATtiny 2313

This example was compiled for the 2313 and may give incorrect results on other processors.*\
The calculation takes 1300 cycles and uses the following algorithm:

```
long factorial(int n);
long result;

int main(void){
  long fact = factorial(8);
  result = fact;
  
  return 0;
}

long factorial(int n){
  if(n != 1)
    return(n * factorial(n-1));
  else
    return 1;
}
```
The result of the calculation is stored in ram at location 0x60. To best see the result, configure the memory panel to show words rather than bytes and switch to decimal representation.

##### *_For example, if  run on the ATmega238, the result of the calculation is in the I/O memory rather than sram. Values in I/O memory may be masked._
