| 235 | } |
| 236 | |
| 237 | NOINLINE static double cost_guess (size_t n) |
| 238 | { |
| 239 | const double lfp=1.1; // penalty for non-hardcoded larger factors |
| 240 | size_t ni=n; |
| 241 | double result=0.; |
| 242 | size_t tmp; |
| 243 | while (((tmp=(n>>1))<<1)==n) |
| 244 | { result+=2; n=tmp; } |
| 245 | |
| 246 | size_t limit=(size_t)sqrt(n+0.01); |
| 247 | for (size_t x=3; x<=limit; x+=2) |
| 248 | while ((tmp=(n/x))*x==n) |
| 249 | { |
| 250 | result+= (x<=5) ? x : lfp*x; // penalize larger prime factors |
| 251 | n=tmp; |
| 252 | limit=(size_t)sqrt(n+0.01); |
| 253 | } |
| 254 | if (n>1) result+=(n<=5) ? n : lfp*n; |
| 255 | |
| 256 | return result*ni; |
| 257 | } |
| 258 | |
| 259 | /* returns the smallest composite of 2, 3, 5, 7 and 11 which is >= n */ |
| 260 | NOINLINE static size_t good_size(size_t n) |
no test coverage detected