Last active
May 11, 2021 10:46
-
-
Save mhmadip/f83809dcf438497a051b05297d34f62b to your computer and use it in GitHub Desktop.
Sum of List Elements Challange - Mohammad Salim IT Dept. @ TIU
This file contains 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
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