solidity/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for.sol
2023-05-11 10:56:55 -05:00

24 lines
514 B
Solidity

contract C {
function f(uint256 a) public returns (uint256 b) {
assembly {
function fac(n) -> nf {
nf := 1
for {
let i := n
} gt(i, 0) {
i := sub(i, 1)
} {
nf := mul(nf, i)
}
}
b := fac(a)
}
}
}
// ----
// f(uint256): 0 -> 1
// f(uint256): 1 -> 1
// f(uint256): 2 -> 2
// f(uint256): 3 -> 6
// f(uint256): 4 -> 24