Looking for variant approach/sketch

for 12!, the above codes takes 921 cycles which is same as taken by the following codes of @robtillaart:

uint32_t factorialI(uint8_t n)
{
  uint32_t fac = n;
  while ((--n) > 1) fac *= n;
  return fac;
}

OUTPUT:

1011
479001600
921
479001600
921
479001600

Will for() loop for iteration instead of post decremental while() loop produce identical result?

1 Like