Skip to content

Instantly share code, notes, and snippets.

@mhmadip
Last active May 11, 2021 10:46
Show Gist options
  • Save mhmadip/f83809dcf438497a051b05297d34f62b to your computer and use it in GitHub Desktop.
Save mhmadip/f83809dcf438497a051b05297d34f62b to your computer and use it in GitHub Desktop.
Sum of List Elements Challange - Mohammad Salim IT Dept. @ TIU
int sum(List<int> intList, int index) {
if (index == 0) {
return intList[index];
} else {
return intList[index] + sum(intList, index - 1);
}
}
void main() {
var test = [4, 2, 3, 4];
var result = sum(test, 3);
print(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment