File: Execute.java
--------------------------------------------------------------
package org.developersbrain.solutions;
public class Execute {
static int randDec=0;
static int start;
public static int random(){
randDec++;
start++;
if(randDec%2==0){
return start>>randDec;
}else{
return start<<randDec;
}
}
public static void main(String[] args){
start=1000;
int n=10;
int printV;
for(int i=0;i<n;i++){
printV=random();
if(printV!=0){
System.out.println(printV+" ");
}else{
i--;
}
}
}
}
Output:
--------------------------------------------
2002
250
8024
62
32160
15
128896
3
516608
2070528
--------------------------------------------------------------
package org.developersbrain.solutions;
public class Execute {
static int randDec=0;
static int start;
public static int random(){
randDec++;
start++;
if(randDec%2==0){
return start>>randDec;
}else{
return start<<randDec;
}
}
public static void main(String[] args){
start=1000;
int n=10;
int printV;
for(int i=0;i<n;i++){
printV=random();
if(printV!=0){
System.out.println(printV+" ");
}else{
i--;
}
}
}
}
Output:
--------------------------------------------
2002
250
8024
62
32160
15
128896
3
516608
2070528
Comments
Post a Comment