14

1

_{(via chat)}

The OEIS entry A123321 lists the sequence of numbers that are the product of seven distinct primes. For brevity, we'll call this a *7DP* number. The first few numbers and their corresponding divisors are below:

```
510510 = 2 * 3 * 5 * 7 * 11 * 13 * 17
570570 = 2 * 3 * 5 * 7 * 11 * 13 * 19
690690 = 2 * 3 * 5 * 7 * 11 * 13 * 23
746130 = 2 * 3 * 5 * 7 * 11 * 17 * 19
```

The challenge here will be to find the closest 7DP number, in terms of absolute distance, from a given input.

### Input

A single positive integer *n* in any convenient format.

### Output

The closest 7DP number to *n*, again in any convenient format. If two 7DP numbers are tied for closest, you can output either or both.

### Rules

- Numbers can be assumed to fit in your language's default
`[int]`

datatype (or equivalent). - Either a full program or a function are acceptable.
- Standard loopholes are forbidden.
- This is code-golf, so all usual golfing rules apply, and the shortest code wins.

### Examples

```
5 -> 510510
860782 -> 870870
1425060 -> 1438710 (or 1411410, or both)
```

Great idea with the divisor counting! I think you can golf the alternating walk by updating

`k`

directly as`f(n+k,k%2*2+~k)`

, starting with`k=0`

. – xnor – 2016-06-09T02:17:41.737Great improvement. Thanks! – Dennis – 2016-06-09T03:51:23.997