Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Go to Problems

# Base conversions for base N

A base N number system has N digits. The process of conversion of N based number to decimal and vice versa is very similar to the binary number system process we just saw.
The only thing that changes is that 2 is replaced by N.
So, if the N based number system representation is `An An-1 ... A2 A1 A0`, then the corresponding decimal value is

``````    A0 * N^0 + A1 * N^1 + A2 * N^2 + ...
``````

The reverse process is also exactly similar. We keep dividing by N, keeping track of the remainders as we go.

Let us say our number is `357`, and `N = 7`.

``````                1       R0
---------
7 |  7       R2
---------
7 |  51      R0
---------
7 |  357
``````

Thus the number converts to `1020` in base 7.

## Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.
Primers
Examples

## Math Problems

Problem Score Companies Time Status
Total Moves For Bishop! 75 30:55
Distribute in Circle! 100 21:33
Prime Sum 150 43:15
Sum of pairwise Hamming Distance 200
66:52
FizzBuzz 200
12:34
Is Rectangle? 200 11:17
Step by Step 200 50:47
Power Of Two Integers 250 39:36
Base conversion
Problem Score Companies Time Status
Excel Column Number 175 23:19
Excel Column Title 175 41:11
Digit op
Problem Score Companies Time Status
Palindrome Integer 200 17:28
Reverse integer 200 28:36
Next Smallest Palindrome! 400 60:21
Number theory
Combinatorics
Problem Score Companies Time Status
K-th Permutation 200 60:31
City Tour 300
61:35
Grid Unique Paths 375 32:35
Hash search
Problem Score Companies Time Status
Highest Score 200 27:59
Bit play
Problem Score Companies Time Status
Number encoding
Problem Score Companies Time Status
Next Similar Number 200 55:07
Rearrange Array 250
49:03
Array dp
Problem Score Companies Time Status
Numbers of length N and value less than K 200
89:59

Problem Score Companies Time Status
Sum of 7's Multiple 200 22:58
Find Last Digit 200 29:54
Last digit K count 200 23:42
Digital Root 200 13:44
Number of Sundays 200 21:28
Product of Digits 150 9:46
Round Table 150 18:32
Odd Even Rule 150 11:20
Armstrong Number 200 13:05
Leap Year 100 9:14
Lowest Common Multiple (LCM) 100 18:14
Which Season? 100 9:59
Socks Pair 100 15:05
Two Stores 150 35:11
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *