I was looking through Weregoose's posts the other day, and I noticed this obfuscated routine:

Code:
"int(NfPart((X²+1)/N→Y1
"gcd(N,abs(max(∆List(Ans→u
Ans→N:{2,2
Repeat u≠1
Y1({Ans(1),Y1(Ans(2:End:u


I have slightly de-obfuscated it to this:


Code:
2→A
2→B
Input N
Repeat Ans≠1
remainder(A²+1,N→A
remainder((B²+1)²+1,N→B
gcd(N,abs(A-B
End
Ans


It looks like it repeatedly calculates X²+1 modulo N, starting from 2, advancing A one step and B two steps each time, until A and B are equal modulo some divisor of N, then outputs that divisor. But I can't figure out the point of the routine. Is it some obscure number-theoretical property? Can anyone help (perhaps Weregoose himself)?

By the way, here's a table of the first few values of A and B (not modulo anything).

Code:
A          B          B-A 
----------------------------
       2          2   0
       5         26   21=3×7
      26     458330   458304=2^6×3×7×11×31
     677   4.413e22   3^3×5^3×7×19×31×37×97×2957×298814209
  458330
2.101e11


EDIT: The sequence is https://oeis.org/A003095, and the period in the residues modulo n is https://oeis.org/A248218. I'm still puzzled.
After the better part of a year, I've discovered that it's Pollard's rho algorithm for factorizing integers. I could test the speed against other factorization algorithms (trial division, Fermat, SQUFOF), but I don't really have time now.
I'll have you know, this topic has sent me on a couple wild goose chases since it first materialized, leaving me to rummage in my old, dilapidated synapse bundle helplessly and fruitlessly. But when you mentioned Pollard's rho, it hit me like a ton of bricks that that is indeed what I was tinkering with so long ago! I'm just glad that this topic's saxjax announcement will finally lead to a night of rest, rather than misery. Very Happy
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement