Advertisement
Guest User

Untitled

a guest
Mar 7th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. static void mark (long[] a, int l, int r)
  2.         {
  3.             int i_sqrt_max = (int)Math.Sqrt(r*2) / 2 + 2;            
  4.             for (int k = 1; k <= i_sqrt_max; k++) //from 1 because multiples of a[0]=2 aren't in the array
  5.             {                        
  6.                 if (a[k] != 0)
  7.                 {
  8.                     for (long i = a[k]+k; i < r; i += a[k])    
  9. //where do I have to start i (in relation to l,k) to avoid repeating the steps from i to l?                
  10.                     {                        
  11.                         a[i] = 0;                                              
  12.                     }
  13.                 }
  14.             }          
  15.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement