Question #27169

(1) A=Pi*r^2
(2) C=n!/r!(n-r)!

Expert's answer

package question.t27169;

public class Test

{

publicstatic void main(String[] args)

{

System.out.println(t1(10));

System.out.println(t2(2,3));

}

/**

* (1) A=Pi*r^2 - formula for the area of acircle

*

* @param r - radius of the circle

* @return

*/

publicstatic double t1(double r)

{

returnMath.PI*r*r;

}

/**

* (2) C=n!/r!(n-r)! - combination Inmathematics a combination is a way of

* selecting several things out of a largergroup, where (unlike

* permutations) order does not matter.

*

* @param r

* @param n

* @return

*/

publicstatic int t2(int r,int n)

{

returnfact(n)/(fact(r)*fact(n-r));

}

/**

* factorial calculation

* @param n

* @return

*/

publicstatic int fact(int n)

{

if(n<1)

{

return1;

}

else

{

returnn*fact(n-1);

}

}

}

public class Test

{

publicstatic void main(String[] args)

{

System.out.println(t1(10));

System.out.println(t2(2,3));

}

/**

* (1) A=Pi*r^2 - formula for the area of acircle

*

* @param r - radius of the circle

* @return

*/

publicstatic double t1(double r)

{

returnMath.PI*r*r;

}

/**

* (2) C=n!/r!(n-r)! - combination Inmathematics a combination is a way of

* selecting several things out of a largergroup, where (unlike

* permutations) order does not matter.

*

* @param r

* @param n

* @return

*/

publicstatic int t2(int r,int n)

{

returnfact(n)/(fact(r)*fact(n-r));

}

/**

* factorial calculation

* @param n

* @return

*/

publicstatic int fact(int n)

{

if(n<1)

{

return1;

}

else

{

returnn*fact(n-1);

}

}

}

## Comments

## Leave a comment