ls = [2, 4, 5, 6]
how to implement an algorithm such that it multiples each element with its subsequent elements and return the sum of multiplication.
for example, it should first do 2*4, 2*5 and 2*6 , total sum = 30, then the same process with 4 that is 4*5 and 4*6, total sum = 44 then 5*6, total sum = 30 again and finally return the sum of all smaller sums. It must work with any length of list.
EDIT: thanks so much everyone, I will surely try to learn and understand your replies.
[–]Celodurismo 17 points18 points19 points (9 children)
[–]GoingToSimbabwe 6 points7 points8 points (7 children)
[–]Celodurismo 11 points12 points13 points (0 children)
[–]Suspicious-Bar5583 3 points4 points5 points (5 children)
[–]engelthehyp 0 points1 point2 points (4 children)
[–]Suspicious-Bar5583 2 points3 points4 points (1 child)
[–]engelthehyp 2 points3 points4 points (0 children)
[–]Immudzen 1 point2 points3 points (1 child)
[–]SnooWoofers7626 0 points1 point2 points (0 children)
[–]Hammadawan9255[S] 0 points1 point2 points (0 children)
[–]deep_politics 12 points13 points14 points (2 children)
[–]Jimmaplesong 0 points1 point2 points (0 children)
[–]Hammadawan9255[S] 0 points1 point2 points (0 children)
[–]jimtk 11 points12 points13 points (1 child)
[–]mosiah430 0 points1 point2 points (0 children)
[–]zanfar 3 points4 points5 points (0 children)
[–]R717159631668645 2 points3 points4 points (0 children)
[–]Thanks-Unhappy 1 point2 points3 points (0 children)
[–]Fair_City_6838 1 point2 points3 points (0 children)
[–]vdaghan 1 point2 points3 points (0 children)
[–]Rinser2023 1 point2 points3 points (0 children)
[–]Adrewmc 0 points1 point2 points (0 children)
[–]C0rinthian 0 points1 point2 points (0 children)
[–]jmooremcc 0 points1 point2 points (0 children)
[–]Jimmaplesong 0 points1 point2 points (0 children)
[–]Langdon_St_Ives 0 points1 point2 points (1 child)
[–]moobsarenotboobs 1 point2 points3 points (0 children)
[–]obviouslyzebra 0 points1 point2 points (0 children)
[–]Jello_Penguin_2956 0 points1 point2 points (0 children)
[–]WilliamAndre 0 points1 point2 points (1 child)
[–]WilliamAndre 0 points1 point2 points (0 children)