from integer to BigInteger

Discussion in 'Java' started by dogy2005, Nov 4, 2010.

  1. dogy2005

    dogy2005

    Joined:
    Nov 4, 2010
    Messages:
    1
    Hello,
    could somebody help me to overwrite my simple program?

    old

    int delitel;
    int cislo;

    for ( cislo = 0; cislo <= 29876; cislo++)

    delitel = 3;
    String retezec = "";

    while (cislo > 0) {
    retezec = (cislo % delitel) + retezec;
    cislo /= delitel;
    }
    System.out.println(retezec);
    }
    }
    }

    new

    import java.math.BigInteger;
    import java.io.*;
    import java.util.*;
    import java.lang.*;

    public class madrid {
    public static void main(String[] arg) {
    {
    BigInteger cislo = new BigInteger("3");
    cislo = cislo.pow(400);

    BigInteger numberB = new BigInteger("1");

    while ( true ) {
    cislo = cislo.add(numberB);
    if ( cislo == cislo.pow(400)) break;

    BigInteger delitel = new BigInteger("3");

    String retezec = "";

    while ( cislo > 0 ) {

    retezec = ( cislo.mod(delitel) ) + retezec;

    cislo = cislo.divide(delitel);

    System.out.println(retezec);
    System.out.println(retezec.length());
    }
    }
    }
    }
    }

    I dont know what to do with this parts

    while ( cislo > 0 ) { //maybe ther must be true
    retezec = ( cislo.mod(delitel) ) + retezec;

    and Idont know if this is correct?
    while ( true ) {
    cislo = cislo.add(numberB);
    if ( cislo == cislo.pow(400)) break;

    insted of

    for ( cislo = 0; cislo <= 29876; cislo++)

    or if somebody can check if everything is correct? Thank You

    result is combination of 0,1,2
     
    dogy2005, Nov 4, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nick
    Replies:
    0
    Views:
    901
  2. nick
    Replies:
    1
    Views:
    31,791
    Eric Sosman
    Oct 26, 2004
  3. Jeremy Watts

    integer to BigInteger

    Jeremy Watts, Nov 6, 2006, in forum: Java
    Replies:
    4
    Views:
    564
    Simon Brooke
    Nov 7, 2006
  4. Jeremy Watts

    converting BigInteger to integer

    Jeremy Watts, Nov 23, 2006, in forum: Java
    Replies:
    1
    Views:
    484
    Eric Sosman
    Nov 23, 2006
  5. varma.chiru@gmail.com

    how to convert BigInteger to integer

    varma.chiru@gmail.com, Nov 29, 2006, in forum: Java
    Replies:
    1
    Views:
    654
    Fred Kleinschmidt
    Nov 29, 2006
Loading...

Share This Page