`{"id":"4acc027b-1f49-48db-8460-abec8fe4202a","name":"Any Base Addition","description":"<p>1. You are given a base b. 2. You are given two numbers n1 and n2 of base b. 3. You are required to add the two numbes and print their value in base b.</p>","inputFormat":"<p>A base b A number n1 A number n2</p>","outputFormat":"<p>A number representing the sum of n1 and n2 in base b.</p>","constraints":"<p>2 &lt;= b &lt;= 10 0 &lt;= n1 &lt;= 256 0 &lt;= n2 &lt;= 256</p>","sampleCode":{"cpp":{"code":"#include<iostream>\r\n\r\nusing namespace std;\r\n\r\nint getSum(int b, int n1, int n2) {\r\n // write your code here\r\n\r\n \r\n}\r\n\r\n\r\nint main() {\r\n int b, n1, n2;\r\n cin >> b >> n1 >> n2;\r\n cout << getSum(b, n1, n2) << endl;\r\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 b = scn.nextInt();\r\n int n1 = scn.nextInt();\r\n int n2 = scn.nextInt();\r\n \r\n int d = getSum(b, n1, n2);\r\n System.out.println(d);\r\n }\r\n \r\n public static int getSum(int b, int n1, int n2){\r\n // write ur code here\r\n }\r\n }"},"python":{"code":"def getSum(b, n1, n2):\n # Write your Code here\n \n\nif __name__ == '__main__':\n b = int(input())\n n1 = int(input())\n n2 = int(input())\n \n solution = getSum(b, n1, n2)\n print(solution)"}},"points":10,"difficulty":"easy","sampleInput":"8\r\n777\r\n1","sampleOutput":"1000","questionVideo":"https://www.youtube.com/embed/LmQeZ74pT_c","hints":[],"associated":[{"id":"326b9a35-fb94-4b8b-b2b9-2d7cd68904d9","name":"(any base addition) we run our while loop untill ________","slug":"any-base-addition-we-run-our-while-loop-untill","type":4},{"id":"357ac5cf-c54b-4651-9333-802465e81469","name":"(Any base addition) What is the Space Complexity of this approach?","slug":"any-base-addition-what-is-the-space-complexity-of-this-approach","type":4},{"id":"62fb1178-3108-442a-9020-7bf83614e6f5","name":"(Any base addition) Hexadecimal number equivalent of decimal 11 is?","slug":"any-base-addition-hexadecimal-number-equivalent-of-decimal-11-is","type":4},{"id":"fc388fed-9d7f-4272-be1f-a42e5d8a3c54","name":"(any base addition) What is the Time Complexity of this approach?","slug":"any-base-addition-what-is-the-time-complexity-of-this-approach","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":"a434cb55-cae2-499d-87b2-6fc0b3f8aa1b","name":"Any Base Addition","slug":"any-base-addition","type":1}],"next":{"id":"9779f8bf-91f4-4268-9783-1b340c9f1d23","name":"Any Base Addition","type":3,"slug":"any-base-addition"},"prev":{"id":"3c8963b8-9f78-40fb-a8a8-1119dae5d642","name":"Any Base To Any Base","type":3,"slug":"any-base-to-any-base"}}}`

<p>1. You are given a base b. 2. You are given two numbers n1 and n2 of base b. 3. You are required to add the two numbes and print their value in base b.</p>

`{"id":"4acc027b-1f49-48db-8460-abec8fe4202a","name":"Any Base Addition","description":"<p>1. You are given a base b. 2. You are given two numbers n1 and n2 of base b. 3. You are required to add the two numbes and print their value in base b.</p>","inputFormat":"<p>A base b A number n1 A number n2</p>","outputFormat":"<p>A number representing the sum of n1 and n2 in base b.</p>","constraints":"<p>2 &lt;= b &lt;= 10 0 &lt;= n1 &lt;= 256 0 &lt;= n2 &lt;= 256</p>","sampleCode":{"cpp":{"code":"#include<iostream>\r\n\r\nusing namespace std;\r\n\r\nint getSum(int b, int n1, int n2) {\r\n // write your code here\r\n\r\n \r\n}\r\n\r\n\r\nint main() {\r\n int b, n1, n2;\r\n cin >> b >> n1 >> n2;\r\n cout << getSum(b, n1, n2) << endl;\r\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 b = scn.nextInt();\r\n int n1 = scn.nextInt();\r\n int n2 = scn.nextInt();\r\n \r\n int d = getSum(b, n1, n2);\r\n System.out.println(d);\r\n }\r\n \r\n public static int getSum(int b, int n1, int n2){\r\n // write ur code here\r\n }\r\n }"},"python":{"code":"def getSum(b, n1, n2):\n # Write your Code here\n \n\nif __name__ == '__main__':\n b = int(input())\n n1 = int(input())\n n2 = int(input())\n \n solution = getSum(b, n1, n2)\n print(solution)"}},"points":10,"difficulty":"easy","sampleInput":"8\r\n777\r\n1","sampleOutput":"1000","questionVideo":"https://www.youtube.com/embed/LmQeZ74pT_c","hints":[],"associated":[{"id":"326b9a35-fb94-4b8b-b2b9-2d7cd68904d9","name":"(any base addition) we run our while loop untill ________","slug":"any-base-addition-we-run-our-while-loop-untill","type":4},{"id":"357ac5cf-c54b-4651-9333-802465e81469","name":"(Any base addition) What is the Space Complexity of this approach?","slug":"any-base-addition-what-is-the-space-complexity-of-this-approach","type":4},{"id":"62fb1178-3108-442a-9020-7bf83614e6f5","name":"(Any base addition) Hexadecimal number equivalent of decimal 11 is?","slug":"any-base-addition-hexadecimal-number-equivalent-of-decimal-11-is","type":4},{"id":"fc388fed-9d7f-4272-be1f-a42e5d8a3c54","name":"(any base addition) What is the Time Complexity of this approach?","slug":"any-base-addition-what-is-the-time-complexity-of-this-approach","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":"a434cb55-cae2-499d-87b2-6fc0b3f8aa1b","name":"Any Base Addition","slug":"any-base-addition","type":1}],"next":{"id":"9779f8bf-91f4-4268-9783-1b340c9f1d23","name":"Any Base Addition","type":3,"slug":"any-base-addition"},"prev":{"id":"3c8963b8-9f78-40fb-a8a8-1119dae5d642","name":"Any Base To Any Base","type":3,"slug":"any-base-to-any-base"}}}` Editor

easy

1. You are given a base b. 2. You are given two numbers n1 and n2 of base b. 3. You are required to add the two numbes and print their value in base b.

## Constraints

2 <= b <= 10 0 <= n1 <= 256 0 <= n2 <= 256

## Format

### Input

A base b A number n1 A number n2

### Output

A number representing the sum of n1 and n2 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;}8 777 1```

### 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;}1000`

Question Video

Discussions

Show Discussion

Related Resources 