Help me, to search factor O(log n)

can you help to search how many odd number at Numbers of Factor

ex : number 8 have factor 1,2,4,8 , result 1
number 9 have factor 1 3 9 , result 3

but my code to long run result because have complexity O(n);
can you convert to O(log n)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

int CountOddFactor(int num)
{ 
      int i, counter=0;	      
      
      for(i=1 ; i<=num; i+=2)
      {
         if (!(num%i) && i%2==1){
         	counter++;
         	printf("%d ",i);
         }				 
      }   
      
    return counter;
}
http://www.cplusplus.com/forum/beginner/27855/
just adapt it to consider only the odds factors
keep in mind that
even x even = even
even x odd = even
odd x odd = odd
Topic archived. No new replies allowed.