Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.2K Views
|
1 Reply
|
1 Total Like
View groups...
Share
Share this post:
GROUPS:

Calculate John Conway's Subprime Fibs with a RecurrenceTable?

Posted 10 years ago

I tried to code John Conway's Subprime Fibs into Mathematica. This is a sequence where each number is the sum of the two previous number, divided by the smallest factor when this sum isn't prime. In the code below everything works correctly except for the recurrence table. The third entry should be 5. Is it me? You can tell me if it is :-)

In[25]:= SD[x_] :=(*smallest divisor not equal to x*)
 If[Or[x == 1, PrimeQ[x]], 1, Divisors[x][[2]]]

SS[x_] := (* x if prime, otherwise x/ smallest prime factor of x *)
   x/SD[x]

In[27]:= S[x_, y_] := 
 SS[x + y] (* x+y devided by it's smallest factor, or itself if prime*)


RecurrenceTable[{a[n + 2] == S[a[n + 1], a[n]], a[1] == 2, 
  a[2] == 3}, a, {n, 10}]

Out[28]= {2, 3, 1, 2, 1, 1, 1, 1, 1, 1}

In[29]:= SD[5]

Out[29]= 1

In[30]:= SS[5]

Out[30]= 5

In[31]:= S[3, 2]

Out[31]= 5
POSTED BY: stephen Morris
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard