Skip to content

Instantly share code, notes, and snippets.

@Davidegloh
Created August 14, 2021 18:28
Show Gist options
  • Save Davidegloh/73c11cd0e0cffe532cffab79bdf07694 to your computer and use it in GitHub Desktop.
Save Davidegloh/73c11cd0e0cffe532cffab79bdf07694 to your computer and use it in GitHub Desktop.
[Loops-Solidity]#loops
//Loops
//While loop
pragma solidity 0.7.5;
contract HelloWorld {
function count(int number) public pure returns(int){
int i = 0;
while (i < 10){
number++;
i++;
}
return number;
}
}
//For loop
contract HelloWorld {
function count(int number) public pure returns(int){
for(int i=0; i<10;i++){
number++;
}
return number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment