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
KEYWORD
easy,nonn,base
AUTHOR
Phil Scovis, Sep 08 2008
STATUS
approved