Reversing a for loop... want to print numbers in reverse

Posted by user69514 on Stack Overflow See other posts from Stack Overflow or by user69514
Published on 2010-04-29T16:59:43Z Indexed on 2010/04/29 17:07 UTC
Read the original article Hit count: 142

Filed under:
|
|
|

How would I change this loop to print prime number in reverse... starting from the biggest one first

int main(){

    bool prime;
    for( int i=3; i<=10000; i++){
        prime = true;
        for(int n=2; n<=i-1; n++){
            if( i%n == 0){
                prime = false;
            }
        }
        if(prime){
            cout << i << " ";
        }
    }
    return 0;

}

© Stack Overflow or respective owner

Related posts about for

    Related posts about loop