CS321/HW2/sa2a.h
inline
int f1(int k, int level)
{
    assert(k > 0);
    assert(level >= 0);

    int count = 0;
    while (k > 1)
    {
        if (k % 2)
            k = 3*k + 1;
        else
            k /= 2;

        int up;
        if (level == 0)
            up = 1;
        else
            up = 1+f1(k, level-1);
        count += up;
    }
    return count;
}
// f1
// Helper function for sa2a.
// Parameter k should be postive; level should be nonnegative.
f1
Helper function for sa2a.
Parameter k should be postive; level should be nonnegative.
f1 Helper function for sa2a . Parameter k should be postive ; level should be nonnegative .
inline
int f1(int k, int level)
{
    assert(k > 0);
    assert(level >= 0);
    int count = 0;
    while (k > 1)
    {
        if (k % 2)
            k = 3*k + 1;
        else
            k /= 2;
        int up;
        if (level == 0)
            up = 1;
        else
            up = 1+f1(k, level-1);
        count += up;
    }
    return count;
}
inline int f1 ( int k , int level ) { assert ( k > 0 ) ; assert ( level >= 0 ) ; int count = 0 ; while ( k > 1 ) { if ( k % 2 ) k = 3 * k + 1 ; else k /= 2 ; int up ; if ( level == 0 ) up = 1 ; else up = 1 + f1 ( k , level - 1 ) ; count += up ; } return count ; }
f1
Helper function for sa2a.
f1 Helper function for sa2a .