Required assistance #1390
-
I am absolutely beginner in coding and just started coding in cpp language. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @SD-4am-ind, Happy coding 👍🏻 |
Beta Was this translation helpful? Give feedback.
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 👍🏻