Create a function which checks a number for three different properties.
Is the number prime?
Is the number even?
Is the number a multiple of 10?Each should return either true or false, which should be given as an array.
Today's challenge comes from sohilpandya on Codewars.
Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (13)
Well, as this isn't the most challenging challenge, I decided to challenge myself ;)
Here is an answer in the stack-based programming language Factor.
I've never tried anything like this before, so I'd be interested in some feedback if any is available.
Conversely, if anyone would like me to explain what on earth is going on above, please ask and I'll do my best. I really enjoyed writing it.
JavaScript
Live demo on CodePen.
Well done!
Rust Solution!
Went with the naive algorithm for testing for a prime number. Could always improve on that if needed :shruggy:
My test cases for these are also getting thinner and thinner as we go on...
Nice!
Perl solution, using the modulo operator.
:) I really enjoyed this.
It was a nice way to start the morning.
I did not know this existed and now I will look forward to this each morning to start my day or to give a break during the day <3
Here is my simple solution with Python:
Go:
Elixir:
My solution in js
I made the answer earlier and forgot to put it here after I solved it in CodeWars lmao
JavaScript answer, Big O time complexity of O(sqrt(n)) to find if N is a Prime Number.