Convert 1 into any positive integer using only the operations *3 and /2 Any positive integer can be obtained by starting with 1 and applying a sequence of operations, each of which is either "multiply by 3" or "divide by 2, discarding any remainder". 

Examples (writing f for *3 and g for /2):

4 = 1 *3 *3 /2 = 1 ffg
6 = 1 ffggf = 1 fffgg
21 = 1 fffgfgfgggf 

Write a program with the following behavior:

Input: any positive integer, via stdin or hard-coded. (If hard-coded, the input numeral will be excluded from the program length.) 
Output: a string of f's and g's such that &lt;input&gt; = 1 &lt;string&gt; (as in the examples). Such a string in reverse order is also acceptable. NB: The output contains only f's and g's, or is empty.

The winner is the entry with the fewest bytes of program-plus-output when 41 is the input.
We're getting dirty, friends! 

JAVA 210 207  199 characters

public class C{public static void main(String[] a){int i=41;String s="";while(i&gt;1){if(i%3&lt;1){s+="f";i/=3;}else if(i%3&lt;2){s+="g";i+=i+1;}else{s+="g";i+=i+(Math.random()+0.5);}}System.out.println(s);}}


non-golfed:

public class C {

    public static void main(String[] a) {

        int i = 41;
        String s = "";
        while (i &gt; 1) {
            if (i % 3 == 0) {
                s += "f";
                i /= 3;
            } else {
                if (i % 3 == 1) {
                    s += "g";
                    i += i + 1;
                } else {
                    s += "g";
                    i += i + (Math.random() + 0.5);
                }
            }
        }
        System.out.println(s);
    }
}


output : depending on the faith of the old gods, the shortest i had was 30. Note that the output must be read from the right. 

234 

1 ggfgfgfgfggfggfgffgfggggfgffgfggfgfggggfgffgfggfgfggfgfggfgfgggggfffgfggfgfggfgfgggffgggggfffgfggggfgffgfggfgfggfgfggfgfggfgfggfgfggfgfggggfgffgfggfgfggfgfggfgfggfgfggfgfggggggggggggfgfgfggggfgfgfggfffgfgfggffgfgfggfgfggggffgfgfffff


108

1 gggffgfgfggggggfggggfgffggggfgfgfgfgfgffgggfgggggfggfffggfgfffffgggffggfgfgggffggfgfgggffggggggfgfgffgfgfff


edit 45

1 ggfgfgfgfgggfggfffgfggfgfgggggggffgffgfgfff


points : 318 199+30 = 229

edit1 (2*i+1)%3==0 --> (2*i) % 3 ==1

Nota Bene if you use Java 6 and not Java 7 while golfing, you can use 

public class NoMain {
    static {
        //some code
        System.exit(1);
    }
}


39 characters structure instead of a standard structure which is 53 characters long.