randomposts
Powered by Blogger.

Write a program to print n step of the following series, 1, 3, 6, 11, 18, 29… Code in Java Programming

No comments


Write a program to print n step of the following series, 1, 3, 6, 11, 18, 29… Code in Java Programming Here...

import java.util.*; ___(Don't Missing Syntax required)
class series
{
     public static void main(String args[])___(Don't Missing Syntax required)
     {
           int r,a,c,n,s;
           Scanner sc=new Scanner(System.in);___(Don't Missing Syntax required)
          
           System.out.print("First Enter The Ranging Number:");___(Don't Missing Syntax required)
           r=sc.nextInt();___(Don't Missing Syntax required)
           n=1;
           s=1;
           while(s<=i)
           {
                c=0;
                a=1;
                while(a<=n)
                {
                     if(n % a == 0)
                     {
                           c=c+1;
                     }
                     a=a+1;
                }
          
                if(c==2)
                {
                     System.out.print(s + ",");___(Don't Missing Syntax required)
                     s=s+n;
                }
                n=n+1;
           }
     }    
}

Note: *Remove The Sentence on this program ___(Don't Missing Syntax required).

No comments :

Post a Comment