Y
Hacker News
new
|
ask
|
show
|
jobs
My Favorite CS Puzzle – An Interactive Walkthrough
(
assaf.dev
)
1 points
by
assafk
566 days ago
1 comments
Sianko
566 days ago
I think the value of a repeated number can be found much easier: ``` long sum = 0; for (int i = 0; i < n; i++) { if(i < n - 1) { sum -= i; } sum += array[i]; }
printf("Element %d\r\n", sum); ```
link
assafk
564 days ago
This doesn't work if more than one value repeats itself.
link
printf("Element %d\r\n", sum); ```