Raised This Month: $ Target: $400
 0% 

Can you make this more efficeint?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
GrimReaperCdn
Member
Join Date: Jul 2007
Location: Steamboat, Colorado
Old 04-02-2008 , 21:32   Can you make this more efficeint?
Reply With Quote #1

Written in C++ and this check's if a number is prime. It's really simple, and it returns '0' if it's prime or '1' if it's not prime.

Wondering if anyone can make this more efficient?

PHP Code:
int IS_prime(double num)
{
    
int isprime 0;
    for(
int i 2<= sqrt(num); += 2)
    {
        if(
== 0)
            
i++;

        if((
int(num)% i) == 0)
        {
            
isprime 1;
            break;
        }
    }

    return 
isprime;

__________________
HARRR!

Last edited by GrimReaperCdn; 04-02-2008 at 23:12.
GrimReaperCdn is offline
Send a message via AIM to GrimReaperCdn Send a message via MSN to GrimReaperCdn
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode