from integer to BigInteger

Joined
Nov 4, 2010
Messages
1
Reaction score
0
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top