`{"id":"c7c12e6c-c591-4f87-8dcb-85335e351ece","name":"Any Base To Decimal","description":"1. You are given a number n.\r\n2. You are given a base b. n is a number on base b.\r\n3. You are required to convert the number n into its corresponding value in decimal number system.","inputFormat":"A number n\r\nA base b","outputFormat":"A decimal number representing corresponding value of n in base b.","constraints":"0 &lt;= d &lt;= 1000000000\r\n2 &lt;= b &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\nusing namespace std;\nint AnyToDec(int n,int b){\n//write your code here.\n}\nint main(){\n int n;\n int b;\n cin >> n;\n cin >> b;\n int res = AnyToDec(n,b);\n cout<<res<<endl;\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int b = scn.nextInt();\r\n int d = getValueIndecimal(n, b);\r\n System.out.println(d);\r\n }\r\n \r\n public static int getValueIndecimal(int n, int b){\r\n // write your code here\r\n }\r\n }"},"python":{"code":"n = int(input());\nb = int(input());\ndef AnyToDec(n,b):\n # Write your code here\nif __name__ == \"__main__\":\n res = AnyToDec(n,b)\n print(res)"}},"points":10,"difficulty":"easy","sampleInput":"111001\r\n2","sampleOutput":"57","questionVideo":"https://www.youtube.com/embed/FybIe62OI6M","hints":[],"associated":[{"id":"311d80db-92e8-481f-8830-33bec9b4cb6b","name":"(ab2d) What is the constraint for the each digit 'd' in a number with base 'b'?","slug":"ab2d-what-is-the-constraint-for-the-each-digit-d-in-a-number-with-base-b","type":4},{"id":"a30b1b73-aff9-44a3-84c5-b7fb0c535a89","name":"(ab2d) Decimal numbers contains digits(values) from ____?___.","slug":"ab2d-decimal-numbers-contains-digits-values-from","type":4},{"id":"f0d02a67-bebf-4cc9-8ddd-4088daca2944","name":"(ab2d) To convert any base to decimal, each digit is ____?____ by base 'b'.","slug":"ab2d-to-convert-any-base-to-decimal-each-digit-is-by-base-b","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"32084e1e-822b-4333-a9a6-8be0c0aac12f","name":"Any Base To Decimal","slug":"any-base-to-decimal","type":1}],"next":{"id":"7a7af2c1-6171-479a-be94-bb4af94e4009","name":"Any base to Decimal","type":3,"slug":"any-base-to-decimal"},"prev":{"id":"4002541f-c89f-4a48-995a-943435f09b8d","name":"Decimal To Any Base","type":3,"slug":"decimal-to-any-base"}}}`

# Any Base To Decimal

1. You are given a number n. 2. You are given a base b. n is a number on base b. 3. You are required to convert the number n into its corresponding value in decimal number system.

`{"id":"c7c12e6c-c591-4f87-8dcb-85335e351ece","name":"Any Base To Decimal","description":"1. You are given a number n.\r\n2. You are given a base b. n is a number on base b.\r\n3. You are required to convert the number n into its corresponding value in decimal number system.","inputFormat":"A number n\r\nA base b","outputFormat":"A decimal number representing corresponding value of n in base b.","constraints":"0 &lt;= d &lt;= 1000000000\r\n2 &lt;= b &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\nusing namespace std;\nint AnyToDec(int n,int b){\n//write your code here.\n}\nint main(){\n int n;\n int b;\n cin >> n;\n cin >> b;\n int res = AnyToDec(n,b);\n cout<<res<<endl;\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int b = scn.nextInt();\r\n int d = getValueIndecimal(n, b);\r\n System.out.println(d);\r\n }\r\n \r\n public static int getValueIndecimal(int n, int b){\r\n // write your code here\r\n }\r\n }"},"python":{"code":"n = int(input());\nb = int(input());\ndef AnyToDec(n,b):\n # Write your code here\nif __name__ == \"__main__\":\n res = AnyToDec(n,b)\n print(res)"}},"points":10,"difficulty":"easy","sampleInput":"111001\r\n2","sampleOutput":"57","questionVideo":"https://www.youtube.com/embed/FybIe62OI6M","hints":[],"associated":[{"id":"311d80db-92e8-481f-8830-33bec9b4cb6b","name":"(ab2d) What is the constraint for the each digit 'd' in a number with base 'b'?","slug":"ab2d-what-is-the-constraint-for-the-each-digit-d-in-a-number-with-base-b","type":4},{"id":"a30b1b73-aff9-44a3-84c5-b7fb0c535a89","name":"(ab2d) Decimal numbers contains digits(values) from ____?___.","slug":"ab2d-decimal-numbers-contains-digits-values-from","type":4},{"id":"f0d02a67-bebf-4cc9-8ddd-4088daca2944","name":"(ab2d) To convert any base to decimal, each digit is ____?____ by base 'b'.","slug":"ab2d-to-convert-any-base-to-decimal-each-digit-is-by-base-b","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"32084e1e-822b-4333-a9a6-8be0c0aac12f","name":"Any Base To Decimal","slug":"any-base-to-decimal","type":1}],"next":{"id":"7a7af2c1-6171-479a-be94-bb4af94e4009","name":"Any base to Decimal","type":3,"slug":"any-base-to-decimal"},"prev":{"id":"4002541f-c89f-4a48-995a-943435f09b8d","name":"Decimal To Any Base","type":3,"slug":"decimal-to-any-base"}}}` Editor

# Any Base To Decimal

easy

1. You are given a number n. 2. You are given a base b. n is a number on base b. 3. You are required to convert the number n into its corresponding value in decimal number system.

## Constraints

0 <= d <= 1000000000 2 <= b <= 10

## Format

### Input

A number n A base b

### Output

A decimal number representing corresponding value of n in base b.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}111001 2```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}57`

Question Video

Discussions

Show Discussion

Related Resources 