WAP in java to print the series 1*2*3

Ads
 

WAP in java to print the series 1*2*3

WAP in java to print the series 123

View Answers

July 12, 2011 at 10:51 AM

import java.util.*;
class Series 
{    
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter value of n: ");
        int num=input.nextInt();
            for(int i=1;i<=num;i++){
                System.out.print(i+" ");
            }
    }
}

July 12, 2011 at 8:43 PM

import java.util.Scanner;
public class Series {
    public static void main(String args[])
    {
        int mul=1;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter value of n: ");
        int num=input.nextInt();
        for(int i=1;i<=num;i++){
            mul=mul*i;
                System.out.println(i+"*="+mul);
            }
    }
}
output:
Enter value of n: 5
1*=1
2*=2
3*=6
4*=24
5*=120
BUILD SUCCESSFUL (total time: 5 seconds)
//Executed successfully

July 13, 2011 at 9:55 AM

import java.util.Scanner;

/**
 *
 * @author Umra
 */
public class Series {
    public static void main(String args[])
    {
        int mul;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter value of n: ");
        int num=input.nextInt();
        for(int i=1;i<=num;i++)
        {
            System.out.println("\n");
            mul=1;
            for(int j=i;j>=1;j--)
            {
                mul=mul*j;
                System.out.print(j+" * ");
            }
            System.out.print("1 ="+mul);
        }
    }
}

output:
Enter value of n: 5


1 * 1 =1

2 * 1 * 1 =2

3 * 2 * 1 * 1 =6

4 * 3 * 2 * 1 * 1 =24

5 * 4 * 3 * 2 * 1 * 1 =120

Ads









Related Tutorials/Questions & Answers:
WAP in java to print the series 1*2*3
java programming:generating series
Advertisements
loop code to print the Pyramid: 1 1234 12 123 123 12 1234 1
java programming:generating series
SERIES PROGRAMMING
printing series in java
java programming:generating series
java programming:generating series
jsp 18/04/2013
oracel 18/04/2013
oracle 18/04/2013
printing java series
Java programming: generating series
series
series
string wap
How to print this in java?
What is WAP?
series printing
series printing
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
code for timer in java netbeans for online test series countdown timer
Java Print Dialog
Simplest way to print an array in Java
print rectangle pattern in java
Maven Dependency java-util >> 1.20.3
How to pretty print XML from Java?
How to print the following pattern in java?

Ads