Octal Equivalent of N
Coding Problem Keys
Octal Equivalent of N
Problem Statement
Given an integer N as input, the program must print the octal equivalent of N.
Boundary Condition(s)
1 <= N <= 10000000
Input Format
The first line contains the value of N.
Output Format
The first line contains the octal equivalent of N.
Example Input/Output 1
Input
4756
Output
11224
Explanation
The octal equivalent of 4756 is 11224.
Example Input/Output 2
Input
49467
Output
140473
Explanation
The octal equivalent of 49467 is 140473.
Note: Max Execution Time Limit: 5000 millisecs
Solution
Programming Language: Python 3 Language
# Published By PKJCODERSprint(oct(int(input()))[2:])
Alter
# Published By PKJCODERSdef decimal_to_octal(decimal): octal = 0 i = 1 while(decimal != 0): octal = octal + (decimal % 8) * i decimal = int(decimal / 8) i = i * 10 return octal decimal = int(input()) print(decimal_to_octal(decimal))
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments