how to sum all the values return after a loop

title^^

closed account (z05DSL3A)
Try to ask the question properly with a bit more detail.
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
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.