Wednesday, July 29, 2026
Latest:
  • Präsentation für b1
  • Verb “werden” Konjugation
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
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

What is interface in Java? What are the differences between interface and class?

February 21, 2020 beroza

How to get number of bits set to 1 of a binary number?

November 7, 2021 beroza

Query in-stock products WooCommerce WordPress.

January 4, 2020 beroza

Keyword “this” is immutable in JavaScript

February 25, 2019 beroza

Error creating bean with name ‘requestMappingHandlerMapping’ spring boot

January 27, 2019 beroza

Some elaboration of commonly used Java technologies?

November 5, 2019 beroza

What is SaaS, PaaS and IaaS? Explain with example

May 9, 2019 beroza

Reactjs app should use a boilerplate or use create-react-app from Facebook?

January 2, 2019 beroza

How to do SFTP using pem file from command line?

May 17, 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.