n32 calls in gp (Pari) rm2(n): divide n by 2 if n is even modd(n): the odd part of n; divide out any power of 2 n32(n,l): compute iterations of odd(3*n+1) with output formatted in vectors of length l (default 10) when 0 < l <100, otherwise no output, returning the number of iterations to 1, *** assuming this number is finite, as conjectured. n32ta(m) = greatest number of iterations of modd(3*x+1) to 1 for all j from 1 to m print the location and the max no. and return the max no. n32t(m) = greatest number of iterations of modd(3*x+1) to 1 for all ODD j from 1 to m print the location and the max no. and return the max no. n32tai(m,n) = greatest number of iterations of modd(3*x+1) to 1 for all j from m to n print the location and the max no. and return the max no. n32ti(m,n) = greatest number of iterations of modd(3*x+1) to 1 for all ODD j from m to n print the location and the max no. and return the max no. n32m(m,n,l): compute iterations of odd(3*n+1) with output reduced mod m and formatted in vectors of length l (default 10) when 0 < l <100 (otherwise no output) returning the number of iterations to 1, assuming this number is finite, as conjectured. Note: the iteration process itself is NOT reduced mod m. n32p2(a,b): compute the no. of iterations of modd(3*x+1) to 1 starting with x = 2^j-1, as j varies from a to b, and return a vector consisting of the j value and the no. of iterations that is largest among these values of j. f32p2(k,l): compute the no. of iterations of modd(3*x+1) to 1 for x = 2^j-1, with j = 2*k-1 and j = 2*k, formatting the n32 output in vectors of length l. rmf(p,x): remove all factors of p from x (return x or 0 if p <=1) fit(a,b,p,x): return a*x+b with the highest possible power of p factored out isinvec(v,n): return position of n in vector v, otherwise 0. augvec(v,n): return vector of size one more than the size of v with last component n. nit(a,b,p,x,verb): iterate z -> (a*z+b)/(highest power of p) from x; stop either when z < x or a cycle is detected. Return last iterate. Use arg verb (optional) to receive iteration information every verb iterations. page 2 rmv(m,x): return the "part" of x that is coprime to m fiv(a,b,p,x): return (a*x+b) made coprime to p niv(a,b,p,x,verb): iterate z -> [ a*z+b made coprime to p] from x; stop either when z < x or a cycle is detected. Print cycle or no. of iterations to end. Return last iterate. Use arg verb (optional) to receive iteration information every verb iterations. nivc(a,b,p,x,verb): iterate z -> [ a*z+b made coprime to p] from x; Stop when a cycle is detected. Use arg verb (optional) to receive iteration information every verb iterations. Return vector with four components: (1) offset for cycle start, (2) offset for cycle end, (3) smallest entry in cycle, (4) the cycle (itself a vector). nivf(a,b,p,x,width): iterate z -> [ a*z+b made coprime to p] from x; stop when a cycle is detected. Print all iterates as generated. width (optional) -- number of iterates per line (default 10) Return vector with four components: (1) offset for cycle start, (2) offset for cycle end, (3) smallest entry in cycle, (4) the cycle (itself a vector). nivck(a,b,p,vec,ia,ib,verb): iterate z -> [ a*z+b made coprime to p] from x for all ia <= x <= ib until a value in the vector vec is found. This is based on the premise that successive such iterations always lead to a cycle belonging to a finite set and that each such cycle has at least one representative member among the coordinates of vec . Note: it is not always the case that such iterations lead to a cycle. Stop when a cycle is detected. Use arg verb (optional) to receive iteration information every verb iterations. Return the maximum number of iterations required along the way. rfiv(a,b,p,x,r,w): iterate [ z -> (az + b) made coprime to p ] starting with x for r iterations, printing w iterates per line, w = 0 or 1 (default 0 = no output); return the r-th iterate nive(a,b,p,s,x,verb): iterate z -> [ a*z+b made coprime to p] from x; Stop when the second occurrence of s is found. Use arg verb (optional) to receive iteration information every verb iterations. page 3 Return vector with five components: (1) offset for the first occurrence of s, (2) offset for the second occurrence of s, (3) smallest entry in cycle delimited by (1) and (2), (4) the cycle (itself a vector) beginning with s, (5) the initial sequence of iterates up to the first occurrence of s. cfmat(v,e) = the continued fraction (2 X 2) matrix of the vector v with (constant) "numerators" e (default e = 1) matact(m,q) = the number obtained by letting the 2 X 2 invertible matrix m act projectively on the number q q2cf(q,e)= the continued fraction of the quadratic number q with constant numerator e (default 1) returned as a vector with two components, each a vector, the first being the cycle and the second being the initial sequence. n32c(n) = the element of the quadratic field of discriminant 5 corresponding to the init-orbit of n under the map x -> [ (3x + 1) made odd ] Note this quadratic number is always of the form (u + w)/v where u and v are integers and w = quadgen(5). If m = [a,b;c,d] = cfmat(the orbit), then [u,v]~ = (-1)^k m [-c c+d]~, where k is the number of terms in the init-orbit. n32cv(n) = the element of the quadratic field of discriminant 5 corresponding to the orbit of n under the map x -> [ (3x + 1) made odd ] n32cv differs from n32c in that it is quite verbose: it prints (1) the part of the orbit of n up to the cycle [1] hypothesizing the eventual existence of this cycle (2) the unimodular integer matrix corresponding to this orbit regarded as the beginning of a continued fraction (3) the reciprocal of the "imaginary" part of the quadratic number (4) the number (3) times the "real" part of the quadratic number n32ci(n) = the vector of two integers [u,v] where (u + w)/v is the element of the quadratic field of discriminant 5 corresponding to the orbit of n under the map x -> [ (3x + 1) made odd ] . (See n32c.) n32cb(n) = the triple consisting of the sign of the determinant and the bottom row of the unimodular integer matrix corresponding to the init-orbit of n under the map x -> [ (3x + 1) made odd ] . (See n32c and cfmat.) cyc2q(v,e) = the real quadratic irrational number whose continued fraction with constant numerator e (default 1) is purely cyclic with cycle v (a vector of positive integers). The returned quadratic is expressed in terms of the quadgen for the number field discriminant. page 4 cf2q([c,v],e) = cf2q(c,v,e) = the real quadratic irrational number having continued fraction with init v and cycle c and constant "numerator" e (default 1). smquad(q) = the "small discriminant" representation of the quadratic number q prqv(q): print verbose information about a quadratic number cf2qv(c,v,e) = the real quadratic irrational number having continued fraction with init v , cycle c and constant "numerator" e (default 1). r2cf(q) = the vector representing the (finite) continued fraction expansion of the rational number q with constant "numerator" e (default 1) vhead(v,n) = vector consisting of the first n coordinates of v If n >= size of v , then vhead(v) = v . vtail(v,n) = vector consisting of the last n coordinates of v If n >= size of v , then vtail(v) = v . nivef(a,b,p,s,x,width): iterate z -> [ a*z+b made coprime to p] from x; Stop when the second occurrence of s is found. Print all iterates as generated. width (optional) -- number of iterates per line (default 10) Return vector with five components: (1) offset for the first occurrence of s, (2) offset for the second occurrence of s, (3) smallest entry in the cycle delimited by (1) and (2), (4) the cycle (itself a vector) beginning with s, (5) the initial sequence of iterates up to the first s. nivqf(a,b,p,s,x,width): iterate z -> [ a*z+b made coprime to p] from x; Stop when the second occurrence of s is found. Print all iterates as generated. width (optional) -- number of iterates per line (default 10) Return vector with three components: (1) offset for the first occurrence of s, (2) offset for the second occurrence of s, (3) smallest entry in the cycle delimited by (1) and (2), prodp(n) = the product of all primes less than or equal to n nivqs(a,b,p,s,x,width): iterate z -> [ a*z+b made coprime to p] from x; Stop when the second occurrence of s is found. Print the SIZES of all iterates as generated. width (optional) -- number of iterates per line (default 10) Return vector with three components: (1) offset for the first occurrence of s, (2) offset for the second occurrence of s, (3) smallest entry in the cycle delimited by (1) and (2), page 5 nivfmod(a,b,p,m,x,width): iterate z -> [ a*z+b made coprime to p] from x; stop when a cycle is detected. Print all iterates mod m as generated. width (optional) -- number of iterates per line (default 10) Return vector with four components: (1) offset for cycle start, (2) offset for cycle end, (3) smallest entry in cycle, (4) the cycle mod m (itself a vector). nivcv(a,b,p,v,w): print the terminating cycle (see nivc) when the map x --> [ (ax + b) made coprime to p ] is iterated beginning with the successive coordinates of the vector v . A non-zero value for w causes iteration counts to be printed every w iterations. nivfm(a,b,p,x,num,width): iterate z -> [ a*z+b made coprime to p] from x; stop when a cycle is detected or otherwise after num iterations. Print all iterates as generated. width (optional) (default 10) is the number of iterates per row Return vector with four components: (1) offset for cycle start, (2) offset for cycle end, (3) smallest entry in cycle, (4) the cycle (itself a vector). The returned values will be null if no cycle has been detected. nivfmmod(a,b,p,n,x,num,width): iterate z -> [ a*z+b made coprime to p] from x; stop when a cycle is detected or otherwise after num iterations. Print all iterates mod n as generated. width (optional) (default 10) is the number of iterates per row Return vector with four components: (1) offset for cycle start, (2) offset for cycle end, (3) smallest entry in cycle, (4) the cycle mod n (itself a vector). The returned values will be null if no cycle has been detected.