Thursday, January 29, 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

Difference Between Element Sum and Digit Sum of an Array

January 21, 2023 beroza

This material file is bad or corrupted, photoshop

June 14, 2019 beroza

Uncaught Error: Invariant Violation: Element type is invalid: expected a string or a class/function but got: object

December 16, 2021 beroza

Uncaught (in promise) SyntaxError: Unexpected token in JSON at position 0

April 18, 2021 beroza

error: variable might not have been initialized Java

November 14, 2019 beroza

HTML5 related interview questions

May 9, 2019 beroza

Write a Program to Merge Two Sorted Lists

May 21, 2023 beroza

What is machine learning? What are different types of machine leanring methods?

July 12, 2020 beroza

How to start a Java spring boot application using Jenkins X?

June 27, 2020 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.