











Problem 10
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
String s1=s.nextLine();
String[] s2=s1.split(“”);
ArrayList arrList=new ArrayList();
ArrayList res=new ArrayList();
for(String i:s2) {
arrList.add(Integer.parseInt(i));
}
System.out.println(Math.pow(2,2));
Math.pow(4, 3);
if(arrList.size()%3!=0) {
int m = arrList.size()%3;
int k=3-m;
for(int i=0;i<k;i++) {
arrList.add(i,0);
}
}
int size=arrList.size()/3;
for(int i=0;i=0) {
if(arrList.get(0)==1) {
sum+= Math.pow(2,p);
}
arrList.remove(0);
p-=1;
}
res.add(sum);
} System.out.println(res);
int index=0;
for(float i:res) {
arrList.add(0, (int) i);
index+=1;
}
Collections.reverse(arrList);
for(int i:arrList) {
System.out.print(i);
}
}
arr=[int(i) for i in input()]
if len(arr)%3!=0:
extraZeroToAdd=len(arr)%3
for i in range(3-extraZeroToAdd):
arr.insert(0,0)
size=len(arr)//3
res=[]
for i in range(int(size)):
c=2
sum=0
while c>=0:
if(arr[0]==1):
sum=sum+2**c
c=c-1
arr.pop(0)
res.append(sum)
print(”.join(str(i) for i in res))
public class BinaryToOctal {
public static void main(String[] args) {
System.out.println(binToOct(“101001”));
}
static int binToOct(String number) {
int dec = Integer.parseInt(number , 2);
int oct = Integer.parseInt(Integer.toOctalString(dec));
return oct;
}
}
c=0
s=0
n=int(input(“Enter number:”))
while n > 0:
r=int(n%10)
p=pow(8,c)
s=s+(r*p)
n=int(n/10)
c=c+1
print(s)
Thanks for contributing your code Febin
#python
binary = input(“Enter any number in Binary Format: “);
if binary == ‘x’:
exit();
else:
temp = int(binary, 2);
p=oct(temp)
a=p.replace(“0o”,””)
print(a)
Thanks for contributing the code Bathula
#python
binary = input(“Enter any number in Binary Format: “);
if binary == ‘x’:
exit();
else:
temp = int(binary, 2);
print(temp)
p=oct(temp)
a=p.replace(“0o”,””)
print(a)
Thanks for contributing the code Bathula