|
|
A322163
|
|
Minimal number of steps needed to get from n to 1, where for n > 1 the next step is to either n-1 or max(a,b) for any a > 1 and b > 1 such that ab=n.
|
|
1
|
|
|
0, 1, 2, 2, 3, 3, 4, 3, 3, 4, 5, 3, 4, 5, 4, 3, 4, 4, 5, 4, 5, 6, 7, 4, 4, 5, 4, 5, 6, 4, 5, 4, 5, 5, 5, 4, 5, 6, 5, 4, 5, 5, 6, 6, 4, 5, 6, 4, 5, 5, 5, 5, 6, 4, 5, 4, 5, 6, 7, 4, 5, 6, 4, 4, 5, 6, 7, 5, 6, 5, 6, 4, 5, 6, 5, 6, 6, 5, 6, 4, 4, 5, 6, 4, 5, 6, 7
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
LINKS
|
|
|
EXAMPLE
|
For n=1, there is nothing to do. Hence a(1)=0.
For n=4, the possible sequences of steps are 4->3->2->1 and 4->2->1. Thus the minimal number of steps needed to reach 1 is a(4)=2.
For n=6, the possible sequences of steps are 6->5->4->3->2->1, 6->5->4->2->1 and 6->3->2->1. Thus the minimal number of steps needed to reach 1 is a(6)=3.
|
|
MATHEMATICA
|
divs[n_] := Append[Select[Most[Divisors[n]], #>= Sqrt[n] &], n-1]; a[0] = 0; a[1] = 0; a[n_] := a[n] = 1 + Min[a/@divs[n]]; Array[a, 100] (* Amiram Eldar, Nov 29 2018 *)
|
|
PROG
|
(C)
#include <stdio.h>
int main ()
{
const int N = 100;
int steps[N + 1];
steps[1] = 0;
for (int n = 2; n <= N; n++) {
int next = n - 1;
for (int i = n - 1; i * i >= n; i--) {
if (n % i == 0) {
if (steps[i] < steps[next]) {
next = i;
}
}
}
steps[n] = 1 + steps[next];
}
for (int n = 1; n <= N; n++) {
printf ("%d %d\n", n, steps[n]);
}
}
(PARI) seq(n)={my(v=vector(n)); for(n=2, n, my(m=v[n-1]); fordiv(n, d, if(d>=n/d && d<n, m=min(m, v[d]))); v[n]=m+1); v} \\ Andrew Howroyd, Nov 29 2018
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|