Created
March 30, 2023 05:20
-
-
Save ashwinYardi/6ac012f8e5774a1b0f35597f6f23c8f0 to your computer and use it in GitHub Desktop.
Demo Library to calculate the factorial of the given number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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