how to sum all the values return after a loop

Sep 18, 2013 at 3:40pm
title^^

Sep 18, 2013 at 3:44pm
closed account (z05DSL3A)
Try to ask the question properly with a bit more detail.
Sep 18, 2013 at 3:54pm
for (int i = 2; i < b; i++)

if (b % i == 0 && prime(i))

now i want wathever pass the if statement to be saved and then sum all the values after
the loop end

Last edited on Sep 18, 2013 at 3:54pm
Sep 18, 2013 at 4:18pm
add them to a vector/array.
Then you can add them together several ways.
1) temp variable
2) loop and add sum
3) std::accumulate
Topic archived. No new replies allowed.