Good evening friends, I'm new to this, they let me make a code from the ulam series (you give a number and if a pair is divided by 2 and if odd it is multiplied by 3 and 1 is added, so until you reach 1 that would be the end) but they ask me to keep the numbers in an arrangement. the lines are generated by a random (1 to 5) while the columns must be 70 although not all are used. The number to use is also a random (from 2 to 209 I get it if I print it in a print but when I try to save it in the array it marks me error ... I leave the code I have waiting for you to help me ...
Random ra=new Random();
int mat [ ] [ ];
int ren,col = 0,rrn,r=0,re,c=0;
boolean vr=false;
rrn=2+ra.nextInt(4);
mat = new int [c ] [ r ];
for(ren=0;ren<rrn;ren++)
{
for(col=0;vr!=true;col++)
{
re=2+ra.nextInt(19);
mat [ren] [col]=re;
while(re!=1)
{
if(re%2!=0)
{
re=(re*3)+1;
}//fin del if
else
{
re=re/2;
}//fin del else
mat[ren] [col]=re;
}// fin del while
vr=true;
}//fin del for col
vr=false;
}//fin del for ren
System.out.println( mat [ren][col]+" : ");