Help for a friendly noob, why don't these two functions produce the same output?? And how can I make the second class do the same as the first class without using the Math.pow and factorial functions?

public class Ch7IterationsAndLoopsReview75pt1 {
public static void main(String[] args){
System.out.print("Your infinite series expansion is: ");
System.out.println(myexp(6,6));
}

public static double myexp(double x, double i){

while(i>0){
return Math.pow(x, i)/(factorial(i))
+ (Math.pow(x, i-1))/(factorial(i-1)) + 1;
} return 1;
}
public static double factorial(double n){
while(n>0){
return n * factorial(n-1);
} return 1;
}

}

public class Ch7IterationsAndLoopsReview75pt2 {
public static void main(String[] args){
System.out.print("Your infinite series expansion is: ");
System.out.println(myexp(3,3));
}

public static double myexp(double x, double i){
while(i>0){

return (x/i * myexp(x, i-1))
+ (x/i-1) * myexp(x, i-1);

} return 1;
}
}


Thanks for all of your help, I've been trying to figure this out for the last freakin' week now
Cheers!