Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials

Core Java
JSP
Servlet
JDBC
Hibernate
Struts 1
Struts 2
JSF
Spring
J2EE
J2ME
Web Services
Ajax
Dojo
MySQL
Latest Comments
XRumer 4 Platinum
is it possible to
Thanks
java
nid help
  All Comments...
 

 

 
Struts Tutorials
*Stuts TOC
*Apache Struts Introduction
* Struts Controller
* Struts Action Class
* Struts ActionFrom Class
* Using Struts HTML Tags
*Struts Validator Framework    
*Client Side Address Validation    
*Struts Tiles
*tiles-defs.xml
*Struts DynaActionForm
*Struts File Upload
*Struts DataSource
*AGGREGATING ACTIONS
*Internationalization
Struts Resources
*Struts Books
*Struts Articles
*Struts Frameworks
*Struts IDE
*Struts Alternative
*Struts Links
*Struts Presentations
*Struts Projects
*Struts Software
*Struts Reference
*Struts Resources
*Other Struts Tutorial
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Finding a Factorial using while loop

                          

In this example we are going to find out the factorial of 12 by using the while loop. In while loop the loop will run until the condition we have given gets true. We are using the scriptlet to calculate the factorial of 12. In the scriptlet we generally writes a java logic in it. The output will be displayed by using the out implicit object used to write the content on the browser.

We can find a factorial of a number by using the temp variable which will help us to calculate the factorial of a number. Take one variable factorial of int type and initialize it as 1. Take another variable value of type int of which you want to calculate the factorial .Now use while loop and pass the condition that until temp> 0, the loop should perform the following task: the factorial =  factorial* temp and keep on decreasing the value of temp by l.

<HTML>
  <HEAD>
    <TITLE>Finding a Factorial using while loop</TITLE>
  </HEAD>
  <BODY>
    <font  size="6" color ="#000080">Finding a Factorial using while loop</font><br>
    <%
        int value = 12, factorial = 1, temp = value;
        while (temp > 0) {
            factorial *= temp;
            temp--;
        }
        out.println("The factorial of " + value + " is " + factorial + ".");
    %>
  </BODY>
</HTML>

 

The output of the program is given below:

                          

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

6 comments so far (post your own) View All Comments Latest 10 Comments:

very good . very helpful for the biginers.
please send me the tutorials with sample programs. both jsp and ejb
thanking u.
ben

Posted by Bens on Monday, 10.8.07 @ 22:17pm | #32525

very nice make...

give more download options.. very helpful for beginers..
thankyou
benny

Posted by Benny Michael on Monday, 10.8.07 @ 22:11pm | #32524

Excelent coding. Easy for beginares

Posted by simmy on Sunday, 07.15.07 @ 22:52pm | #21342

Absolutely gr8 way to make beginners familiar abt JSP.

Posted by Raja on Tuesday, 03.13.07 @ 13:06pm | #11569

The tutorial is simply good and is very useful for the beginners.

Posted by sireesha on Thursday, 02.15.07 @ 20:20pm | #7982

please send me jsp each every programming on the basis of application programming

Posted by azhar on Wednesday, 01.31.07 @ 18:27pm | #4944

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.