Skip to content

Instantly share code, notes, and snippets.

@ashwinYardi
Created March 30, 2023 05:20
Show Gist options
  • Save ashwinYardi/6ac012f8e5774a1b0f35597f6f23c8f0 to your computer and use it in GitHub Desktop.
Save ashwinYardi/6ac012f8e5774a1b0f35597f6f23c8f0 to your computer and use it in GitHub Desktop.
Demo Library to calculate the factorial of the given number.
pragma solidity ^0.8.17;
library Factorial {
function factorial(uint n) public pure returns (uint) {
uint result = 1;
for (uint i = 1; i <= n; i++) {
result *= i;
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment