Hướng dẫn python program to convert decimal to octal using recursion - chương trình python để chuyển đổi thập phân sang bát phân bằng cách sử dụng đệ quy

Vấn đề: Viết một chương trình bằng Python để chuyển đổi số thập phân thành biểu diễn bát phân tương ứng của nó. Write a Program in Python to convert a decimal number into its corresponding octal representation.

Example:

Input:  8
Output: 10

Input:  15
Output: 17

Chuyển đổi thập phân sang bát phân trong Python bằng cách sử dụng vòng lặp

Hướng dẫn python program to convert decimal to octal using recursion - chương trình python để chuyển đổi thập phân sang bát phân bằng cách sử dụng đệ quy

Cách tiêu chuẩn để chuyển đổi số thập phân thành một bát phân là chia số thập phân cho 8 cho đến khi giảm xuống còn 0.

Sau khi phân chia kết thúc, nếu chúng ta xếp các phần còn lại theo cách từ dưới lên, giá trị kết quả sẽ là số octal tương đương.

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))

Output::

Nhập số thập phân: 15 nhị phân 15 là: 17
Binary of 15 is: 17

Chuyển đổi thập phân sang bát phân trong Python bằng cách sử dụng đệ quy

Để chuyển đổi thập phân thành bát phân bằng cách sử dụng đệ quy, chúng tôi chuyển chỉ số (cổ tức/8) sang cuộc gọi đệ quy tiếp theo và đầu ra giá trị còn lại (cổ tức%8).

Chúng tôi lặp lại quá trình cho đến khi số giảm xuống 0 (nghĩa là cho đến số thập phân> 0).

Kể từ khi đệ quy thực hiện ngăn xếp, phần còn lại được in theo cách từ dưới lên và chúng tôi nhận được số octal tương đương.

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)

Output::

Nhập số thập phân: 8 Octal: 10
Octal: 10

Chuyển đổi thập phân sang bát phân bằng OCT ()

Phương pháp Python tích hợp oct() trả về biểu diễn bát phân của số thập phân được truyền dưới dạng tham số.

Nó trả về một số bát phân dưới dạng 0oxyz, trong đó xyz là giá trị số bát giác thực tế.

>>> print(oct(15))
0o17

Nhận xét bên dưới nghi ngờ hoặc đề xuất của bạn nếu bạn có bất kỳ.

Đưa ra một số thập phân làm đầu vào, chúng ta cần viết một chương trình để chuyển đổi số thập phân đã cho thành một số bát phân tương đương. tức là chuyển đổi số với giá trị cơ sở 10 thành giá trị cơ sở 8. Giá trị cơ sở của hệ thống số xác định số chữ số được sử dụng để biểu diễn giá trị số. Ví dụ: hệ thống số nhị phân sử dụng hai chữ số 0 và 1, hệ thống số octal sử dụng 8 chữ số từ 0-7 và hệ thống số thập phân sử dụng 10 chữ số 0-9 để biểu thị bất kỳ giá trị số nào.

Ví dụ: & nbsp; 

Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41

Algorithm:  :  

  1. Lưu trữ phần còn lại khi số được chia cho 8 trong một mảng.
  2. Chia số cho 8 bây giờ
  3. Lặp lại hai bước trên cho đến khi số không bằng 0.
  4. In mảng theo thứ tự ngược lại ngay bây giờ.

Ví dụ: & nbsp;

Nếu số thập phân đã cho là 16. & nbsp;

Bước 1: Phần còn lại khi 16 được chia cho 8 là 0. Do đó, ARR [0] = 0. & NBSP; được chia cho 8, là 2. Do đó, ARR [1] = 2. & nbsp; Bước 4: chia 2 cho 8. Số mới là 2/8 = 0. & nbsp; Bước 5: Vì số trở thành = 0. & nbsp;: Remainder when 16 is divided by 8 is 0. Therefore, arr[0] = 0. 
Step 2: Divide 16 by 8. New number is 16/8 = 2. 
Step 3: Remainder, when 2 is divided by 8, is 2. Therefore, arr[1] = 2. 
Step 4: Divide 2 by 8. New number is 2/8 = 0. 
Step 5: Since number becomes = 0. 

Dừng các bước lặp lại và in mảng theo thứ tự ngược lại. Do đó, số octal tương đương là 20.

Sơ đồ dưới đây cho thấy một ví dụ về việc chuyển đổi số thập phân 33 thành số octal tương đương. & NBSP; & nbsp;

Hướng dẫn python program to convert decimal to octal using recursion - chương trình python để chuyển đổi thập phân sang bát phân bằng cách sử dụng đệ quy

Dưới đây là việc thực hiện ý tưởng trên. & Nbsp; & nbsp;

C

#include

void

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
6

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
9

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
4

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
5

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
7
>>> print(oct(15))
0o17
3
>>> print(oct(15))
0o17
9
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
0

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
9

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()1 oct()2

>>> print(oct(15))
0o17
0

C++

oct()4

oct()5 oct()6 oct()7

void

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
6

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
9

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
5

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
5

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3#include 6

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
9

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()1 oct()2

>>> print(oct(15))
0o17
0

oct()5 oct()6 oct()7

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
4

Java

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
00
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
01

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
02
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1____114
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
15
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1____117
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
18
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
19

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
31
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
32
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
35
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
32
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
222__123
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
52

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
27
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
29

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
46
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
47
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
48
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
50

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
9

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

>>> print(oct(15))
0o17
0

Python3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
59

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
64
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
65
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
72
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
73

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
75
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
17
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
79
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
80
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
18

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
93
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
95
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
96
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
32

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
95
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1______202

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
83
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
08
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
47

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
2
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
13
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
14
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
15
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
16__

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
27
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
28
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
30

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
95
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
65

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
34

C#

oct()5

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
36

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
02
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
0
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1____114
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
15
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
52

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
9

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
4

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
6

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
5

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
73

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
80

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
9

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

>>> print(oct(15))
0o17
0

PHP

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
91

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
92
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
05

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
98
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
01
>>> print(oct(15))
0o17
02

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
>>> print(oct(15))
0o17
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
>>> print(oct(15))
0o17
07

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
98
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
17
>>> print(oct(15))
0o17
01
>>> print(oct(15))
0o17
14
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
>>> print(oct(15))
0o17
16

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
>>> print(oct(15))
0o17
19
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
>>> print(oct(15))
0o17
21

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
01
>>> print(oct(15))
0o17
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
29
>>> print(oct(15))
0o17
30
>>> print(oct(15))
0o17
31
>>> print(oct(15))
0o17
01

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
39
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
98
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
17
>>> print(oct(15))
0o17
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
19

>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
>>> print(oct(15))
0o17
46

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
0
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
94
>>> print(oct(15))
0o17
49

>>> print(oct(15))
0o17
50

JavaScript

>>> print(oct(15))
0o17
51

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
92
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
34

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
15
>>> print(oct(15))
0o17
58

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
60

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
2

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
4

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
67

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
8

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
2
>>> print(oct(15))
0o17
74

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
76

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
79

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
9

>>> print(oct(15))
0o17
82

Độ phức tạp về thời gian: O (log n) & nbsp; O(log N) 

Độ phức tạp không gian: O (n) Kể từ khi tạo mảng để lưu trữ các số bát phân since creating array to store octal numbers

Một cách tiếp cận khác: (O (1) Độ phức tạp không gian)

Vấn đề này cũng có thể được giải quyết mà không cần sử dụng mảng & nbsp; sử dụng thuật toán sau:

  • Khởi tạo num octal thành 0 và CountVal đến 1 và số thập phân là n
  • Tìm phần còn lại khi số thập phân chia cho 8
  • Cập nhật số Octal của Octalnum + (phần còn lại * CountVal)
  • Tăng CountVal của CountVal*10
  • Chia số thập phân cho 8
  • Lặp lại từ bước thứ hai cho đến khi số thập phân bằng không

Dưới đây là việc thực hiện ý tưởng trên:

C++

oct()4

oct()5 oct()6 oct()7

void

>>> print(oct(15))
0o17
88
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
90

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
94

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
97

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
03

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
05

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
07

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
09

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
13

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
22

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()1 oct()2

>>> print(oct(15))
0o17
0

C

#include

void

>>> print(oct(15))
0o17
88
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
90

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
94

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
97

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
03

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
05

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
07

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
09

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
7
>>> print(oct(15))
0o17
3
>>> print(oct(15))
0o17
9
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
57

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
22

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()1 oct()2

>>> print(oct(15))
0o17
0

C

Java

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
02
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
00
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
01

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
78
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
90

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
85
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
87
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
47
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
97

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
95
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
29

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
05

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30oct()06oct()07
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30oct()10
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
32
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3oct()16

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1 oct()00
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
32
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
59

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3oct()32

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

>>> print(oct(15))
0o17
0

Python3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
64
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
65
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
24

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
72 oct()37

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
75
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()43
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
47

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()47
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76 oct()49

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1 oct()52
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
23
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
91

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
75
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
08
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76 oct()57
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
80 oct()68

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3oct()43
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76 oct()43
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
80 oct()07

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3oct()59
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
03
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
03
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
32

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
27oct()83

oct()84 oct()85

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76 oct()88oct()89

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
95
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
65

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4oct()95

C#

oct()5

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
36

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
02
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
78
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
90

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
94

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
05

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
07

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
09

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
30oxyz26

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void 0oxyz330oxyz340oxyz35

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3oct()32

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

>>> print(oct(15))
0o17
0

JavaScript

>>> print(oct(15))
0o17
51

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
92 0oxyz48

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
40oxyz51

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
40oxyz53

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
30oxyz58

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
05

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
07

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
30oxyz64

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
40oxyz680oxyz69
>>> print(oct(15))
0o17
49

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
79

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
22

>>> print(oct(15))
0o17
82

Độ phức tạp về thời gian: O (log n)O(log N)

Không gian phụ trợ: O (1) O(1)

Sử dụng hàm được xác định trước

Java

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
00
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
01

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
02
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
78
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
90

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
30oxyz91

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
94

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3xyz07

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

>>> print(oct(15))
0o17
0

Python3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
30
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
27
>>> print(oct(15))
0o17
3xyz16xyz17

oct()84 oct()85

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76 oct()88oct()89

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
95
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
76
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
65

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4xyz07

C#

oct()5

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
36

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
02
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
03

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
78
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
90

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3xyz47

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
>>> print(oct(15))
0o17
94

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
7

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
3xyz61

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
>>> print(oct(15))
0o17
0

>>> print(oct(15))
0o17
0

JavaScript

>>> print(oct(15))
0o17
51

def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
92 0oxyz48

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4xyz70

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
def dectoOct(decimal):
    if(decimal > 0):
        dectoOct((int)(decimal/8))
        print(decimal%8, end='')
        
decimal = int(input("Enter a decimal number: "))
print("Octal: ", end='')
dectoOct(decimal)
1
Input : 16
Output: 20

Input : 10
Output: 12

Input : 33
Output: 41
00

xyz07

>>> print(oct(15))
0o17
82

C++

xyz76

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
40oxyz680oxyz69
>>> print(oct(15))
0o17
49

Độ phức tạp về thời gian: O (log n)

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4xyz85

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4xyz87

Không gian phụ trợ: O (1)

>>> print(oct(15))
0o17
0

Sử dụng hàm được xác định trước

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
3

Java

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4xyz99

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
00
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
01

>>> print(oct(15))
0o17
0

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void 0oxyz85
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
1
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
2

decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
4
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
56
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
05 void
decimal = int(input("Enter a decimal number: "))
octal = 0
ctr = 0
temp = decimal  #copying number
 
#computing octal using while loop
while(temp > 0):
    octal += ((temp%8)*(10**ctr))  #Stacking remainders
    temp = int(temp/8)             #updating dividend
    ctr += 1
       
print("Binary of {x} is: {y}".format(x=decimal,y=octal))
59


Làm thế nào để bạn chuyển đổi thập phân sang bát phân?

Trong thập phân thành nhị phân, chúng tôi chia số cho 2, theo số thập phân thành thập lục phân, chúng tôi chia số cho 16. Trong trường hợp thập phân thành Octal, chúng tôi chia số cho 8 và viết phần còn lại theo thứ tự ngược lại để có được số octal tương đương .divide the number by 8 and write the remainders in the reverse order to get the equivalent octal number.

Làm thế nào để bạn chuyển đổi một số thập phân thành thập lục phân trong Python?

Phương pháp 1: Sử dụng hàm hex () hàm hex () là một trong những hàm tích hợp trong python3, được sử dụng để chuyển đổi số nguyên thành dạng thập lục phân tương ứng của nó.Using hex() function hex() function is one of the built-in functions in Python3, which is used to convert an integer number into its corresponding hexadecimal form.

Làm thế nào để bạn chuyển đổi thập phân thành nhị phân trong Python?

Trong Python, chúng ta chỉ có thể sử dụng hàm bin () để chuyển đổi từ giá trị thập phân sang giá trị nhị phân tương ứng của nó.Bin () lấy một giá trị làm đối số của nó và trả về một nhị phân tương đương.Lưu ý: Bin () Trả về giá trị nhị phân với tiền tố 0b, do đó tùy thuộc vào trường hợp sử dụng, nên thực hiện định dạng để loại bỏ 0b.use the bin() function to convert from a decimal value to its corresponding binary value. The bin() takes a value as its argument and returns a binary equivalent. Note: bin() return binary value with the prefix 0b, so depending on the use-case, formatting should be done to remove 0b.

Làm thế nào để bạn in thập phân nhị phân thập phân trong Python?

Mã nguồn # Chương trình Python để chuyển đổi thập phân thành các hệ thống số khác dec = 344 in ("Giá trị thập phân của", dec, "là:") in (bin (dec), "in nhị phân."), "Trong Octal.") In (hex (dec), "trong thập lục phân.") Giá trị thập phân của 344 là: 0b101011000 trong nhị phân.0o530 trong bát phân.0x158 trong thập lục phân.print(bin(dec), "in binary.") print(oct(dec), "in octal.") print(hex(dec), "in hexadecimal.") The decimal value of 344 is: 0b101011000 in binary. 0o530 in octal. 0x158 in hexadecimal.