22
Dec
Find out a number is prime number or not?
Related Blog Items
- Questions asked in various job interviews (in Programming)
- inline bool isprime()
- Clipping and Clamping with out 'if condition'
- Little, Big endianess explained
- Find Max and Min of two integers without branching
Here is a code snippet which find out whether a number is prime or not,
Please post if you have a better solution….
Solution:
/* returns true if number is prime else 0 */ int prime(int n) { int i; if (!(n % 2)) { return (n == 2); } for(i = 3; i < n; i ++) { if (!(n % i)) return 0; } return 1; }
Popularity: 8%
You need to log on to convert this article into PDF
Related Blog Items - Questions asked in various job interviews (in Programming)
- inline bool isprime()
- Clipping and Clamping with out 'if condition'
- Little, Big endianess explained
- Find Max and Min of two integers without branching
Related Blog Items
- Questions asked in various job interviews (in Programming)
- inline bool isprime()
- Clipping and Clamping with out 'if condition'
- Little, Big endianess explained
- Find Max and Min of two integers without branching
No Comments
No comments yet.