6 kyu
(a+b)^n
92 of 433LearningFTW
Description:
Similar but fairly harder version : Linked
Create a function that takes a integer number n
and returns the formula for as a string. (Input --> Output)
0 --> "1"
1 --> "a+b"
2 --> "a^2+2ab+b^2"
-2 --> "1/(a^2+2ab+b^2)"
3 --> "a^3+3a^2b+3ab^2+b^3"
5 --> "a^5+5a^4b+10a^3b^2+10a^2b^3+5ab^4+b^5"
The formula for n=5
is like so :
So the answer would look like so : a^5+5a^4b+10a^3b^2+10a^2b^3+5ab^4+b^5
Important notes :
- Your string may not have spaces so you can't do this :
a^5 + 5a^4 b + 10a^3 b^2...
- You will show raised to power of by
^
and not using**
. - You need not put
*
between each multiplication - There is no need to show
a^1
orb^1
since that is basicallya
andb
a^0
and/orb^0
also don't need be shown instead be a normal person and use1
since that is what they equate to.- You will need to handle both
positive and negative numbers + 0
- Note :
- You will not be tested for float (only negative integers and whole numbers)
- input
n
goes from -200 to 200.
You will need to use BigInt since otherewise it will not work for both JS and Java
Mathematics
Algebra
Strings
Stats:
Created | Sep 15, 2021 |
Published | Sep 15, 2021 |
Warriors Trained | 1973 |
Total Skips | 40 |
Total Code Submissions | 3417 |
Total Times Completed | 433 |
JavaScript Completions | 92 |
Python Completions | 274 |
Ruby Completions | 23 |
Java Completions | 55 |
C Completions | 25 |
Total Stars | 58 |
% of votes with a positive feedback rating | 92% of 101 |
Total "Very Satisfied" Votes | 85 |
Total "Somewhat Satisfied" Votes | 15 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 26 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |