[ create a new paste ] login | about

Link: http://codepad.org/XY51WArJ    [ raw code | output | fork ]

C++, pasted on Feb 17:
#include<iostream>
using namespace std;
int c,i,m,p,r;
bool k;
int D(long long n)
{
    int s=0;
    k=false;
    while(n>1)
    {
        if(n==p)k=true;
        if(n%2)n=n*3+1;
        else n/=2;
        s++;
    }
    return s;
}
int main()
{
    p=248;
    m=1<<20;
    for(i=1;i<=m;i++)
    {
        r=D(i);
        if(k==true&&r>=c)
        {
            cout<<i<<' '<<r<<endl;
            c=r;
        }
    }
    return 0;
}


Output:
1
2
Line 5: error: ISO C++ does not support 'long long'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: