diff --git a/WebProjectTest/WebContent/index.html b/WebProjectTest/WebContent/index.html index 6aca27d..f9c5f3c 100644 --- a/WebProjectTest/WebContent/index.html +++ b/WebProjectTest/WebContent/index.html @@ -8,9 +8,9 @@

hola mundos

    -
  1. aprende a multiplicar!
  2. -
  3. aprende a factorializar!
  4. -
  5. aprender conversion decimal/binario!
  6. +
  7. aprende a multiplicar!
  8. +
  9. aprende a factorializar!
  10. +
  11. aprender conversion decimal/binario!
diff --git a/WebProjectTest/build/classes/com/roshka/webprojecttest/servlets/FactorialServlet.class b/WebProjectTest/build/classes/com/roshka/webprojecttest/servlets/FactorialServlet.class index b185e4f..c6c8696 100644 Binary files a/WebProjectTest/build/classes/com/roshka/webprojecttest/servlets/FactorialServlet.class and b/WebProjectTest/build/classes/com/roshka/webprojecttest/servlets/FactorialServlet.class differ diff --git a/WebProjectTest/src/com/roshka/webprojecttest/servlets/FactorialServlet.java b/WebProjectTest/src/com/roshka/webprojecttest/servlets/FactorialServlet.java index 218e005..989d039 100644 --- a/WebProjectTest/src/com/roshka/webprojecttest/servlets/FactorialServlet.java +++ b/WebProjectTest/src/com/roshka/webprojecttest/servlets/FactorialServlet.java @@ -1,6 +1,7 @@ package com.roshka.webprojecttest.servlets; +import java.math.BigInteger; import java.io.IOException; import java.io.PrintWriter; @@ -15,6 +16,7 @@ public class FactorialServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + System.out.println("dentro del doGet"); PrintWriter pw = new PrintWriter(resp.getOutputStream()); Boolean valido=true; String parametro = req.getParameter("number"); @@ -43,9 +45,11 @@ public class FactorialServlet extends HttpServlet { negative(pw); } else{ - long facto=1; - for (long i = 2; i <=numero;i++) - facto*=i; + BigInteger facto = BigInteger.ONE; + for (Integer i = 2; i <=numero; i++) { + facto = facto.multiply(new BigInteger(i.toString())); + System.out.printf("factoActual[%d]: ", i, facto ); + } factoDisplay(pw, numero, facto); } } @@ -53,7 +57,8 @@ public class FactorialServlet extends HttpServlet { pw.close(); } - void factoDisplay(PrintWriter pw, Integer numero, Long facto) { + void factoDisplay(PrintWriter pw, Integer numero, BigInteger facto) { + System.out.println("dentro del factoDisplay"); pw.write("" + "" + "Hola, bienvenidos al factorializador" @@ -61,13 +66,13 @@ public class FactorialServlet extends HttpServlet { + "" + "

Soy un generador de factorial de numeros

" + "
" - + "
" + + "" + "Introduzca el numero:
" + "" + "
" + "
" + "
" - + "

El factorial de "+ numero+" es: " + facto +"

" + + "

El factorial de "+ numero+" es: " + facto.toString() +"

" + "
" + "" + ""); @@ -112,7 +117,7 @@ public class FactorialServlet extends HttpServlet { + "" + "

Soy un factorializador

" + "
" - + "
" + + "" + "Introduzca el numero:
" + "" + "
"