Skip to main content
3 events
when toggle format what by license comment
Feb 19, 2020 at 1:18 comment added iSR5 @Milliorn but still is not covered, test your original IsPrime with 0 and -1, it would return true, which are false results. So, the adjustment would solve that. because your method is exposed, so you need to consider to implement its own validations and don't depend on GetDivisors validations only. For the int[] you can use the IEnumerable<int> as private method, and create an overload to call it back and use ToArray() this would return int[] and it would be much faster.
Feb 18, 2020 at 22:11 comment added Milliorn For your IsPrime method, I see that you've covered most conditions, but you forgot to cover 0, 1, and -n cases, which you can just do with a small change on this line : Reason for that is due to this. Take an integer n > 1 and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return null public static IEnumerable<int> I completely agree that this would be optimal. I am however bound to returning an int[] for this. Very interesting stats you posted. Gives me a great perspective.
Feb 18, 2020 at 11:42 history answered iSR5 CC BY-SA 4.0