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
print the following series
java programming:generating series
SERIES PROGRAMMING
Series program in Java - Java Beginners
printing series in java
oracle 18/04/2013
jsp 18/04/2013
oracel 18/04/2013
java programming:generating series
wap
java programming:generating series
printing java series
Java programming: generating series
series
series
How to print this in java?
series printing
series printing
Print Form - Java Beginners
Java Print Dialog
What is WAP?
print rectangle pattern in java
string wap
print a rectangle - Java Beginners
Simplest way to print an array in Java
Maven Dependency java-util >> 1.20.3
Java Print the all components
how to print - Java Beginners

Ads