Skip to content

Instantly share code, notes, and snippets.

@n1c01a5
Last active January 30, 2017 11:23
Show Gist options
  • Save n1c01a5/c684a67416ff715439d8567f7b47e353 to your computer and use it in GitHub Desktop.
Save n1c01a5/c684a67416ff715439d8567f7b47e353 to your computer and use it in GitHub Desktop.
#2 – basic iterator smart contract on Ethereum
contract BasicIterator
{
uint8[10] integers;
function BasicIterator() {
uint8 x = 0;
while(x < integers.length)
{
integers[x] = x;
x++;
}
}
function getSum() returns (uint) {
uint8 sum;
uint8 x;
while(x < integers.length)
{
sum += integers[x];
x++;
}
return x;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment