Wednesday, February 4, 2026
Latest:
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
  • How Spring framework resolves circular dependencies?
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Write a program to convert a binary number to decimal number using recursion

Published: November 7, 2022Last updated: December 26, 2022 binary, code, decimal, recursion

Converting binary numbers to decimal numbers is a little tricky. The base of binary numbers is 2. The following code segment converts a binary number to a string.

(function(){
    // Write a program to convert a binary number to a decimal number using recursion

    const getDecimal = (n) => {
        if (!n) {
            return 0;
        } 
        return  n[0] * (2 ** (n.length - 1)) + getDecimal(n.slice(1))
    };
 
    console.log(getDecimal('111')) // 7
})();

You May Also Like

How to convert timestamp to date object in JavaScript?

April 15, 2021 beroza

What are the differences between Map vs Object in JavaScript?

August 30, 2021 beroza

Construct Binary Search Tree from Preorder Traversal

January 16, 2023 beroza

Minimum Changes To Make Alternating Binary String

January 11, 2023 beroza

java.lang.IllegalStateException: Ambiguous handler methods mapped for ‘/’

January 21, 2019 beroza

Babel vs Webpack: What are the differences?

August 27, 2021 beroza

How to load CSS file based on condition using ReactJS hook?

October 8, 2020 beroza

TypeError: Cannot read property ‘prepareStyles’ of undefined

October 23, 2019 beroza

Some elaboration of commonly used Java technologies?

November 5, 2019 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2026 Upokary. All rights reserved.