The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » sci.math.* » sci.math

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Project Euler Problem 167
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
mukesh tiwari

Posts: 80
Registered: 6/10/07
Project Euler Problem 167
Posted: Jul 11, 2009 9:36 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello Everyone
I am trying to solve the project euler problem 167(http:// I did some home
work and wrote a c++ code to generate ulam numbers but it is not fast
enough. I found something interesting on mathworld (http:// ) and online integer sequence
( . According to
online integer sequence U(2,5) ulam sequence can be generated as A(n)
=A(n-32)+126 leaving first six terms. I also found a paper of M.C.
Wunderlich ( ) but
this paper is not accessible to my university. Can any one please send
me to mukeshtiwariDOTiiitmATgmailDOTcom. My problem is how to generate
all the terms efficiently and how to find a cycle.For Example U(2,5)
lead to cycle 32 leaving first 6 terms so how to find about others.Is
there any proof on the upper bound of cycles in sequecne U(2,2n+1).

Thanking you
Mukesh Tiwaro

Here is my C++ code.
using namespace std;

int main()

int ulam_1[1003];
int n=2;
for(int cnt=0;cnt<1000;cnt++)
for(int i=0;i<n;i++)
{ for(int j=i+1;j<=n;j++)

//cout<<ulam_1[i]<<"---+----"<<ulam_1[j]<<" ";

for(map<int,int>::iterator it=M.begin();it!=M.end();it++)
if(it->first<=ulam_1[n]) continue;
if(it->second>=2) continue;
//cout<<it->first<<"--->"<<it->second<<" ";

cout<<"inserting ulam = "<<ulam_1[n]<<" "<<n<<endl;

//for(int i=6;i+32<1000;i++)
//if(ulam_1[i]+126==ulam_1[i+32]) cout<<"found with perriod 32
"<<ulam_1[i]<<" "<<ulam_1[i+32]<<endl;

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.