public class Loops3
{
    public static int fact(int n)
    {   //pre: n >= 0
        int result = 1;
        for(int mult = 2; mult <= n; mult++)
        {   result *= mult;
        }
        return result;
    }

    private static boolean basesCompliments(char c1, char c2)
    {   return (c1 == 'A' && c2 == 'T') ||
               (c1 == 'T' && c2 == 'A') ||
               (c1 == 'G' && c2 == 'C') ||
               (c1 == 'C' && c2 == 'G');
    }

    public static boolean compliments(String s1, String s2)
    {   //pre: none
        boolean comp = s1.length() == s2.length();
        if( comp )
        {   int pos = 0;
            char c1, c2;
            while( comp && pos < s1.length() )
            {   c1 = s1.charAt(pos);
                c2 = s2.charAt(pos);
                comp = basesCompliments(c1, c2);
                pos++;
            }
        }
        return comp;
    }
    


    public static boolean wellFormedDNA(String strand)
    {   int position = 0;
        boolean wellFormed = true;
        char c;
        while(wellFormed && position < strand.length() )
        {   c = strand.charAt(position);
            wellFormed = c == 'A' || c == 'G' || c == 'T'
                || c == 'C';
            position++;
        }
        return wellFormed;
    }
}
