mercredi 27 juillet 2016

Which will take less time during execution?

In many programs, I have to take mod with 1000000007 and for bigger calculation I have to put it in the loop.

Here I have two options for doing this.

First:`

for(int i=0;i < n;i++){

   //my code for count

   count%=1000000007;
}

Second:`

for(int i=0;i<n;i++){ 

    // my code for count

    if(count > 1000000007)
        count%=1000000007;
}`

I want to know which will take lesser time during execution.

Aucun commentaire:

Enregistrer un commentaire