login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A327439 a(0)=1. If a(n-1) and n are relatively prime and a(n-1)!=1, a(n) = a(n-1) - 1. Otherwise (i.e., if a(n-1) and n share a common factor or a(n-1)=1), a(n) = a(n-1) + gcd(a(n-1),n) + 1. 1
1, 3, 2, 1, 3, 2, 5, 4, 9, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 3, 2, 5, 4, 9, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
Graphically at large scales this sequence is vaguely self-similar, though in certain sections it acts in a rough manner, in particular in regions surrounding apparent cusps. See the program for a graph to zoom in on these sections.
See program for zoomable graph.
{I assume "program" refers to the Python program? - N. J. A. Sloane, Apr 09 2020)
LINKS
MATHEMATICA
a[0] = 1; a[n_] := a[n] = If[a[n - 1] != 1 && CoprimeQ[n, a[n - 1]], a[n - 1] - 1, a[n - 1] + GCD[a[n - 1], n] + 1]; Array[a, 101, 0] (* Amiram Eldar, Feb 24 2020 *)
PROG
(Python)
import math
import matplotlib.pyplot as plt
num = 10000
x = []
y = []
# y is the main sequence
def sequence():
a = 1
y.append(a)
for i in range(num):
if (a != 1) and (math.gcd(a, i+1) == 1):
a -= 1
else:
a += math.gcd(a, i+1)+1
x.append(i)
y.append(a)
x.append(num)
sequence()
# code only regarding the plot.
plt.xlim(0, num)
plt.ylim(0, num)
plt.plot(x, y)
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('Plot of Sequence')
plt.show()
CROSSREFS
Sequence in context: A107460 A353298 A152975 * A244758 A230493 A128262
KEYWORD
nonn,look
AUTHOR
Nathaniel J. Strout, Feb 24 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 15:11 EDT 2024. Contains 371914 sequences. (Running on oeis4.)