Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I have onbe question about using Java with Akka Actors Develop an actor prog

ID: 3865051 • Letter: H

Question

Hi, I have onbe question about using Java with Akka Actors

Develop an actor program for computing Fibonacci numbers concurrently. Particularly, create an actor which receives a request for a particular Fibonacci number from a client actor. If it is one of the base cases, the actor replies with a message containing the answer; otherwise, it creates the two sub-problems you would normally create in a recursive implementation. It then creates two new (Fibonacci) actors, and hands one subproblem to each. Once it has received replies from these actors, it adds them to produce its result, and sends it back to the computation's client.

Thanks!!

Explanation / Answer


//To print the fibonacci series concurrently
public class Actor {

public static void main(String args[]){

int n;
int f0 = 0;
int f1 = 1;
       int fn;
       Symtem.out.println(f0+","+f1);
for(int i=2; i < febCount; i++){
fn = f0 + f1;
           f0 = f1;
           f1 = fn;
       Symtem.out.println(","+fn);
}
}
}

//To print the fibonacci series recursively

public class Actor {
       int n;

public static void main(String args[]){
       Symtem.out.println(fibonacci(0));
}
  
   public void fibonacci(int num)
   {
   if(num == 0)
   {
   num = num + 1;
   fibonacci(num);
   }
   else
   if(num > n)
   {
   return num;
   }
   else
   {
       num = num + fibonacci(num)
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote