Created
April 8, 2021 15:17
-
-
Save cleanunicorn/894620e8eebcf8093f06ff9b985747bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| contract A { | |
| uint[10] list = [1,2,3,4,5,6,7,8,9,10]; | |
| function loop(uint _n) public view returns (uint) { | |
| uint sum = 0; | |
| uint start = list.length - 1; | |
| uint end = list.length - _n; | |
| for (uint i = start; i >= end; i--) { | |
| sum += list[i]; | |
| } | |
| return sum; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment