cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A322163 #23 May 04 2019 14:01:51
%S A322163 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,
%T A322163 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,
%U A322163 6,5,6,4,5,6,5,6,6,5,6,4,4,5,6,4,5,6,7
%N 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.
%H A322163 Antoine Mathys, <a href="/A322163/b322163.txt">Table of n, a(n) for n = 1..20000</a>
%e A322163 For n=1, there is nothing to do. Hence a(1)=0.
%e A322163 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.
%e A322163 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.
%t A322163 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 *)
%o A322163 (C)
%o A322163 #include <stdio.h>
%o A322163 int main ()
%o A322163 {
%o A322163     const int N = 100;
%o A322163     int steps[N + 1];
%o A322163     steps[1] = 0;
%o A322163     for (int n = 2; n <= N; n++) {
%o A322163         int next = n - 1;
%o A322163         for (int i = n - 1; i * i >= n; i--) {
%o A322163             if (n % i == 0) {
%o A322163                 if (steps[i] < steps[next]) {
%o A322163                     next = i;
%o A322163                 }
%o A322163             }
%o A322163         }
%o A322163         steps[n] = 1 + steps[next];
%o A322163     }
%o A322163     for (int n = 1; n <= N; n++) {
%o A322163         printf ("%d %d\n", n, steps[n]);
%o A322163     }
%o A322163 }
%o A322163 (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
%K A322163 nonn
%O A322163 1,3
%A A322163 _Antoine Mathys_, Nov 29 2018