Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Fact
- {
- private int fact=1;
- public void calcFact(int n)
- {
- for(int i=n;i>1;i--)
- fact=fact*i;
- }
- public int getFact()
- {
- return fact;
- }
- }
- class TestFact
- {
- public static void main(String... args)
- {
- Fact f=new Fact();
- f.calcFact(3);
- System.out.println("factorial of the number is = " + f.getFact() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement