login
A144049
Number of different cycles of digits in the hexadecimal (base-16) expansions of 1/p, 2/p, ..., (p-1)/p where p = n-th prime different from 2.
0
2, 4, 2, 2, 4, 8, 2, 2, 4, 6, 4, 8, 6, 2, 4, 2, 4, 2, 2, 8, 2, 2, 8, 8, 4, 2, 2, 12, 16, 18, 2, 8, 2, 4, 10, 12, 2, 2, 4, 2, 4, 2, 8, 4, 2, 2, 6, 2, 12, 8, 2, 40, 10, 64, 2, 4, 2, 12, 8, 6, 4
OFFSET
1,1
EXAMPLE
For n=3, p=7. 1/7 in hexadecimal = 0.249249249... with a period of 3. (p-1)/3 = 2. a(3)=2.
PROG
(C#.NET)
public static void Main() { int b = 16; for( int n = 3; n < 300; n += 2 ) { if( !IsPrime( n ) ) { continue; } if( b % n == 0 ) { continue; } int t = 0; int x = 1; while( true ) { t++; x *= b; int d = x / n; x %= n; if( x == 1 ) { break; } } Console.Write( (double)(n-1) / t ); Console.Write(", "); } } private static bool IsPrime( int n ) { if( n % 2 == 0 ) { return false; } int test = (int)Math.Floor( Math.Sqrt( n ) ); test -= ( 1 - test % 2 ); while( test >= 3 ) { if( n % test == 0 ) { return false; } test--; } return true; }
CROSSREFS
A006556 for a similar sequence using decimal expansions.
Sequence in context: A340129 A213433 A294354 * A368435 A058384 A255671
KEYWORD
easy,nonn,base
AUTHOR
Phil Scovis, Sep 08 2008
STATUS
approved