Elite Coders Society
Hello Guest!
Join us here in this forum!
Please Log in or Register to access more feature in this site.
Start Learning!

† Copyright ©️ 2011 - EliteCoders.forums.ag †
Elite Coders Society
Hello Guest!
Join us here in this forum!
Please Log in or Register to access more feature in this site.
Start Learning!

† Copyright ©️ 2011 - EliteCoders.forums.ag †


Start sharing and learning new skills about programming and design by building connections with other professional and students.
 
HomeForumRecursion Java (Factoring + Triangle) 2a512xyPortalLatest imagesGalleryRecursion Java (Factoring + Triangle) Dw6hztSearchRecursion Java (Factoring + Triangle) 2ns506pRecursion Java (Factoring + Triangle) 2dt2b75RegisterLog in
Elite Coders Partner Links

EliteCoders™️ News!
Hello Guest!, Welcome in our forum. Be active!

Share | 
 

 Recursion Java (Factoring + Triangle)

View previous topic View next topic Go down 
AuthorMessage
Admin[dElmARk]
Admin[dElmARk]
Forum Owner
Forum Owner

Posts : 78
EC-Points : 6304
Thanked : 21
Join date : 15/10/2011
Age : 29
Location : Philippines

Hacker's Info
Hacking Exp:
Recursion Java (Factoring + Triangle) Left_bar_bleue0/0Recursion Java (Factoring + Triangle) Empty_bar_bleue  (0/0)
Hacker Type: White Hat
Hacking Title:

Recursion Java (Factoring + Triangle) Empty
PostSubject: Recursion Java (Factoring + Triangle)   Recursion Java (Factoring + Triangle) EmptyMon Dec 05, 2011 7:38 am

Recursion Java (Factoring + Triangle)

Code:
import java.util.*;
class Recursion{
    public static void main(String []args){
    Scanner ss = new Scanner(System.in);
    System.out.print("Type "1" for Factorial or type "2" for Triangle ");
    int ch = ss.nextInt();
        if(ch == 1){
        System.out.print("Enter a number to find its Factorial: ");
        int a = ss.nextInt();
        int fact = 1;
            for (int i= 1; i<=a; i++){
            System.out.println(fact + " times " + i + " = " + fact*i);
            fact=fact*i;
            }
            System.out.println("The Factor of "+a+" is "+ +fact);
        }
        else if(ch == 2){
        System.out.print("Enter a base number to to get the sum of the elements of the Triangle: ");       
        int j = ss.nextInt();
        int a = 1;
            for (int i= 1; i<=j; i++){
            a=i*(i+1)/2;
            System.out.println(a);
            }
        System.out.println("The sum of the elements of the triangle is " + a);
       
        }else{
        System.out.println("Invalid Input! \nProgram Exit");
        }
    }
}
Back to top Go down
 

Recursion Java (Factoring + Triangle)

View previous topic View next topic Back to top 

 Similar topics

-
» Cashier Java
»  Employee Java
» Compiling Java Program
» Magic Square Java
» Java Basic Syntax (E-Book)
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Elite Coders Society :: Software Development :: Java Programming :: Java Programming-

Protected by Copyscape Duplicate Content Finder
Powered By EliteCoders™

Elite Coders Partner Links
GreyPhantomYour Link HereYour Link HereYour Link Here
Yahoo!GoogleFacebookForumotion