Scene 34 of Dynamic Programming in Core Technical Interview Questions for Software Engineers
By Amin Ariana — November 2013
You are given n, a positive integer. Return true if n is a prime number, and false if it's not.
Problem Statement
You are given n, a positive integer. Return true if n is a prime number, and false if it's not.
Evaluation
- Correct idea: 25%
- Answer with no bugs: 25%
- Square Root optimization: 25%
- Memoization suggestion: 25%
Solution
My one liner solution in Ruby without memoization:
Testing:
References
Asked by Noah Kindler. Video http://vimeo.com/79718197 , his blog: http://www.codewod.com/ .