Required assistance #1390
|
I am absolutely beginner in coding and just started coding in cpp language. |
Answered by
Shriharsh-Deshmukh
Oct 12, 2024
Replies: 1 comment 1 reply
|
Hi @SD-4am-ind, Happy coding 👍🏻 |
1 reply
Answer selected by
SD-4am-ind
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @SD-4am-ind,
To find out whether the given number is Prime or Not you can use for(int i=2;i<=n;i++).
But, it takes more time as it iterate till n th iteration. To minimize the iteration count we use i/2 instead of n as it reduces the iteration count to half. also to reduce beyond that you can use for(int i=2; i*i<=n;i++).
Happy coding 👍🏻