Computer Science, asked by harsh3870, 11 months ago

Wap in java to find sum of given series S=1+1+2+3+5​........ to n terms

Answers

Answered by sswaraj04
31

Answer:

public class series {

   public static void main(String[] args) {

   int n,val=0,val1=1,sum=1;

   for(int i=0;i<n-1;i++)

   {

     int k=val+val1;

     sum+=k;

     val=val1;

      val1=k;

   }

   System.out.println(sum);

}}

Explanation:

##add value of n in program

*********************


harsh3870: v.good thanks
Answered by anantgourav83
6

please follow me and mark me brainliest also....

Attachments:
Similar questions