211
Off-Topic / Re: How to win more stakes!!!
« on: April 09, 2017, 11:05:59 am »
Worked for me thanks!
Register now to gain access to all of our forum features. Once registered and logged in, you will be able to create topics, post replies, send private messages, manage your profile, chat with other players in the shoutbox and much more. Once you sign in, this message will disappear.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Use this function to check if a number is prime or not:
int is_prime(int num)
{
if (num <= 1) return 0;
if (num % 2 == 0 && num > 2) return 0;
for(int i = 3; i < num / 2; i+= 2)
{
if (num % i == 0)
return 0;
}
return 1;
}
If you looking for faster code use sqrt(num) instead of num/2 in the loop.
Forgot to mention however in this assignment I am not allowed to use anything other than int main ()
:/
it would've been super easy with functions tho ;P
Thanks, adam.