Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A081878
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A081878 Triangle read by rows in which row n begins with n (n=1,2,3,...) and iterates the process of dividing n by 2 if n is even, adding 3 if n is an odd prime, otherwise adding 1; stopping when either 1 or 3 is reached. +0
2
1, 2, 1, 3, 4, 2, 1, 5, 8, 4, 2, 1, 6, 3, 7, 10, 5, 8, 4, 2, 1, 8, 4, 2, 1, 9, 10, 5, 8, 4, 2, 1, 10, 5, 8, 4, 2, 1, 11, 14, 7, 10, 5, 8, 4, 2, 1, 12, 6, 3, 13, 16, 8, 4, 2, 1, 14, 7, 10, 5, 8, 4, 2, 1, 15, 16, 8, 4, 2, 1, 16, 8, 4, 2, 1, 17, 20, 10, 5, 8, 4, 2, 1, 18, 9, 10, 5, 8, 4, 2, 1, 19, 22, 11, 14 (list; graph; listen)
OFFSET

1,2

COMMENT

The number of steps to reach 1 or 3 is in A081879.

The sequence is well defined: iteration of f (the map defining the sequence) terminates either at 1 or 3 for all values of n>0. Proof: Assuming that all natural numbers < k converge, then if k is even it converges (as f(k)=k/2 < k) and if it is odd, then f(f(k)) is either (k+1)/2 or (k+3)/2, and these are less than k for all k>4.

EXAMPLE

1; 2,1; 3; 4,2,1; 5,8,4,2,1; 6,3; 7,10,5,8,4,2,1; ...

PROGRAM

(PARI) xnprp3(n) = { for(x=1, n, p1 = x; print1(x" "); while(p1>1, if(p1%2==0, p1/=2, if(isprime(p1), p1+=3, p1 = p1+1; )); print1(p1" "); if(p1==3, break) ) ) }

(MIT Scheme) (define (isprime? n) (cond ((< n 4) (> n 1)) (else (let loop ((i (floor->exact (/ n 2)))) (cond ((= 1 i) #t) ((zero? (modulo n i)) #f) (else (loop (-1+ i))))))))

(define (A081878 upto-n) (let outloop ((x 1) (a (list))) (cond ((> x upto-n) (reverse! a)) (else (let inloop ((a (cons x a))) (let ((n (car a))) (cond ((and (not (= 1 n)) (not (= 3 n))) (cond ((even? n) (inloop (cons (/ n 2) a))) ((isprime? n) (inloop (cons (+ n 3) a))) (else (inloop (cons (1+ n) a))))) (else (outloop (1+ x) a)))))))))

CROSSREFS

Cf. A081879.

Sequence in context: A112384 A123390 A088208 this_sequence A088606 A140073 A131389

Adjacent sequences: A081875 A081876 A081877 this_sequence A081879 A081880 A081881

KEYWORD

easy,nonn,tabf

AUTHOR

Cino Hilliard (hillcino368(AT)gmail.com), Apr 12 2003

EXTENSIONS

Edited by Antti Karttunen (his-firstname.his-surname(AT)iki.fi) and Jud McCranie (j.mccranie(AT)comcast.net), Jun 03, 2003

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified July 25 07:41 EDT 2008. Contains 142293 sequences.


AT&T Labs Research