Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I'm so sorry!
Please use spoiler flag next time, your post was visible in the homepage.
Seems you guys find an "a" number in the array that gives the formula answer.
I looped both "a" and "b" and gave timeout error :)
a * b + b
=> a * b + 1 * b
=> b * (a + 1)
// b is the common factor here.
a*b + b = 0
"b" goes in front of the brackets, causing the quation to look like:
b*(a+1) = 0
Thereforfe, ab+b = b(a+1)
How did we go from
a * b + b
tob * (a + 1)
??This fails at least for n equals 5, 15, 32, 90, 189, 527, 1104, 3074, 6437, 17919 and 37520, because it doesn't check a != b
nice, this is arithmetic progression, but I forget it
thank you I like this
really cool answer, although it requires knowing maths rather than coding
Very nice !
I don't quite understand how logical IF operators are used here. Can someone explain?
This comment is hidden because it contains spoiler information about the solution
thats neat!thanks
@nabramow
you could test it yourself in the console.All it does is convert it to a number, convert to Boolean, then finally convert it back to a number
(operand -> number -> Boolean -> number).
Unary Plus or "+" converts an operand to a number, provided it is in an integer format. E.G.
+"5"
=>5
. The first use of it converts a string integer to an integer. Then second use of it converts the Boolean (true or false) to its integer equivalent; false = 0, true = 1.Logical NOT operator or "!" will return true if the operand is empty or non-functional, and return false if it's not empty or it's functional. In terms of integers, this means it will return false if the integer is not equal to 0. It does this by negating the operand. E.G.
!5
=> false.Loading more items...