{"id":"a56ad0a4-2f98-402c-bf23-a56670e3e6f5","name":"Any Base Multiplication","description":"1. You are given a base b.\r\n2. You are given two numbers n1 and n2 of base b.\r\n3. You are required to multiply n1 and n2 and print the value.","inputFormat":"A base b\r\nA number n1\r\nA number n2","outputFormat":"A number of base b equal in value to n2 * n1.","constraints":"2 &lt;= b &lt;= 10\r\n0 &lt;= n1 &lt;= 10000\r\n0 &lt;= n2 &lt;= 10000","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\n\r\n\r\nint getProduct(int b, int n1, int n2){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int b, n1, n2;\r\n cin>>b>>n1>>n2;\r\n cout<<getProduct(b,n1,n2)<<endl;\r\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic 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 = getProduct(b, n1, n2);\r\n System.out.println(d);\r\n }\r\n\r\n public static int getProduct(int b, int n1, int n2){\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"def getSum(b, n1, n2):\n ans = 0\n carry = 0\n power = 1\n while n1 > 0 or n2 > 0 or carry > 0:\n d1 = n1 % 10\n n1 = n1//10\n d2 = n2 % 10\n n2 = n2 //10\n digit = d1 + d2 + carry\n\n carry = digit//b\n digit = digit % b\n\n ans = ans + (digit * power)\n power = power * 10\n\n return ans\n\ndef getProductWithSingleDigit(base , n1 , d2):\n # write your code here\n\ndef getProduct(base , n1 , n2):\n # write your code here\n\n\nif __name__ == '__main__':\n base = int(input())\n n1 = int(input())\n n2 = int(input())\n \n solution = getProduct(base , n1 , n2)\n print(solution)"}},"points":10,"difficulty":"easy","sampleInput":"5\r\n1220\r\n31","sampleOutput":"43320","questionVideo":"https://www.youtube.com/embed/gB7H8BQ1s1w","hints":[],"associated":[{"id":"185898f1-6d50-4f10-a2ee-339e2901c914","name":"(any base mult) What is the space complexity of the function?","slug":"any-base-mult-what-is-the-space-complexity-of-the-function","type":4},{"id":"66383298-6802-426a-8a72-0aae905432de","name":"(Any base mult) Which while statement has the correct condition to add two numbers and return their value in base b?","slug":"any-base-mult-which-while-statement-has-the-correct-condition-to-add-two-numbers-and-return-their-value-in-base-b","type":4},{"id":"c5c526ef-2dad-42f1-b1b7-35f16df658d1","name":"(any base mult) How can we find the carry in this question?","slug":"any-base-mult-how-can-we-find-the-carry-in-this-question","type":4},{"id":"caf76622-f114-44d0-8987-bcef8ed043ec","name":"(Any base mult) What is the time complexity?","slug":"any-base-mult-what-is-the-time-complexity","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":"fca994e1-05a2-4264-ab85-ff98812291bd","name":"Any Base Multiplication","slug":"any-base-multiplication","type":1}],"next":{"id":"1a2afe19-2098-4e85-a977-d353103a03de","name":"Any Base Multiplication","type":3,"slug":"any-base-multiplication"},"prev":{"id":"1d28de58-d30c-4110-8f6a-cd99806ad904","name":"Any Base Subtraction","type":3,"slug":"any-base-subtraction"}}}

Any Base Multiplication

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

{"id":"a56ad0a4-2f98-402c-bf23-a56670e3e6f5","name":"Any Base Multiplication","description":"1. You are given a base b.\r\n2. You are given two numbers n1 and n2 of base b.\r\n3. You are required to multiply n1 and n2 and print the value.","inputFormat":"A base b\r\nA number n1\r\nA number n2","outputFormat":"A number of base b equal in value to n2 * n1.","constraints":"2 &lt;= b &lt;= 10\r\n0 &lt;= n1 &lt;= 10000\r\n0 &lt;= n2 &lt;= 10000","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\n\r\n\r\nint getProduct(int b, int n1, int n2){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int b, n1, n2;\r\n cin>>b>>n1>>n2;\r\n cout<<getProduct(b,n1,n2)<<endl;\r\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic 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 = getProduct(b, n1, n2);\r\n System.out.println(d);\r\n }\r\n\r\n public static int getProduct(int b, int n1, int n2){\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"def getSum(b, n1, n2):\n ans = 0\n carry = 0\n power = 1\n while n1 > 0 or n2 > 0 or carry > 0:\n d1 = n1 % 10\n n1 = n1//10\n d2 = n2 % 10\n n2 = n2 //10\n digit = d1 + d2 + carry\n\n carry = digit//b\n digit = digit % b\n\n ans = ans + (digit * power)\n power = power * 10\n\n return ans\n\ndef getProductWithSingleDigit(base , n1 , d2):\n # write your code here\n\ndef getProduct(base , n1 , n2):\n # write your code here\n\n\nif __name__ == '__main__':\n base = int(input())\n n1 = int(input())\n n2 = int(input())\n \n solution = getProduct(base , n1 , n2)\n print(solution)"}},"points":10,"difficulty":"easy","sampleInput":"5\r\n1220\r\n31","sampleOutput":"43320","questionVideo":"https://www.youtube.com/embed/gB7H8BQ1s1w","hints":[],"associated":[{"id":"185898f1-6d50-4f10-a2ee-339e2901c914","name":"(any base mult) What is the space complexity of the function?","slug":"any-base-mult-what-is-the-space-complexity-of-the-function","type":4},{"id":"66383298-6802-426a-8a72-0aae905432de","name":"(Any base mult) Which while statement has the correct condition to add two numbers and return their value in base b?","slug":"any-base-mult-which-while-statement-has-the-correct-condition-to-add-two-numbers-and-return-their-value-in-base-b","type":4},{"id":"c5c526ef-2dad-42f1-b1b7-35f16df658d1","name":"(any base mult) How can we find the carry in this question?","slug":"any-base-mult-how-can-we-find-the-carry-in-this-question","type":4},{"id":"caf76622-f114-44d0-8987-bcef8ed043ec","name":"(Any base mult) What is the time complexity?","slug":"any-base-mult-what-is-the-time-complexity","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":"fca994e1-05a2-4264-ab85-ff98812291bd","name":"Any Base Multiplication","slug":"any-base-multiplication","type":1}],"next":{"id":"1a2afe19-2098-4e85-a977-d353103a03de","name":"Any Base Multiplication","type":3,"slug":"any-base-multiplication"},"prev":{"id":"1d28de58-d30c-4110-8f6a-cd99806ad904","name":"Any Base Subtraction","type":3,"slug":"any-base-subtraction"}}}
plane

Editor


Loading...

Any Base Multiplication

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 multiply n1 and n2 and print the value.

Constraints

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

Format

Input

A base b A number n1 A number n2

Output

A number of base b equal in value to n2 * n1.

Example

Sample Input

5 1220 31

Sample Output

43320

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode