Skip to content

Commit

Permalink
Solution Task5 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
AK-007 authored and mubaris committed Jan 19, 2018
1 parent ff07c45 commit 18bb4c0
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Solutions/AK-007/Task5/thread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import java.util.*;
import java.lang.*;
import java.io.*;
class Factorial extends Thread{
int k;

Factorial(int a)
{
this.k=a;
}
@Override
public void run()
{
if(k==1)System.out.println("Factorial : 1");
else
{
int i=1,ans=1;
while(i<=k)
{
ans*=i;
i++;
}
System.out.println("Factorial : "+ans);
}
}
}
class Exponential extends Thread{

int k;
Exponential(int a)
{
this.k=a;
}
@Override
public void run()
{
int ans=(int) Math.pow(k,k);
System.out.println("Exponential : "+ans);
}
}
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();

Factorial f=new Factorial(n);
Exponential e=new Exponential(n);

f.start();
e.start();
f.join();
e.join();
}
}

0 comments on commit 18bb4c0

Please sign in to comment.