Skip to content

Conversation

@mstecrd
Copy link

@mstecrd mstecrd commented Oct 20, 2023

The sumOfNaturalNumbers function calculates the sum of the first N natural numbers using a simple loop.

We use the library to measure the execution time of the sumOfNaturalNumbers function.

We record the starting time with std::chrono::high_resolution_clock::now() before calling the function and the ending time after the function execution.

We calculate the duration of the operation and print it in microseconds using std::chrono::duration_cast.

The sumOfNaturalNumbers function calculates the sum of the first N natural numbers using a simple loop.

We use the <chrono> library to measure the execution time of the sumOfNaturalNumbers function.

We record the starting time with std::chrono::high_resolution_clock::now() before calling the function and the ending time after the function execution.

We calculate the duration of the operation and print it in microseconds using std::chrono::duration_cast.
@sunnyshahabuddin sunnyshahabuddin added the hacktoberfest-accepted Accept for hacktoberfest, will merge later label Oct 20, 2023
@sunnyshahabuddin sunnyshahabuddin merged commit 5716a52 into sunnyshahabuddin:master Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Accept for hacktoberfest, will merge later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants