Question
What does the following C function compute? Discover.
int some fun(int n)
{
if(n%2 == 0)
return 2;
int d, s = sqrt(n);
for(d = 3; d <= s; d = d+2)
if(n%d == 0)
return d;
return n;
}
Answer :
Word Count : 187
___ ________ ___ ________ ____ _______ ___ _______ _________ _________ __________ _____.
__________ _______ ____ _________ ______ _______.
_______ _________ _______ _______ ____ _____ _______ _________ ____.
__________ ________ _______ ____ _______ ________ ____ ______ __________ ____ _______ ___.
_____ ________ _____ _______ ____ _____ ________ _______ _________.
________ ______ _____ __________ ______ _____ __________.
_____ ____ _____ _____ _______ __________ _________ _______ _______ _______.
_______ ___ _____ __________ ____ ____ _______ ___ _____.
__________ ________ ____ __________ _________.
____ _________ _________ ___ ________ _______ _____ _______ ___.
___ _____ _________ ______ ______ _____ _________ __________ _________ ____.
_____ ___ ______ __________ ________.
___ _________ _____ _________ ____ _____ ____.
______ ______ ___ _________ ______ ________ _______ _____ _____ ____ ___ ___.
_______ _____ ____ __________ _____ ______ ____ _______ _________ ________.
__________ _____ _________ ______ ______ ____ _____ ___ ____.
______ _________ ___ _________ ____.
Skip in 10
The given C function some_fun takes an integer n as input and returns an integer as output.
If n is an even number, the function immediately returns the value 2. This is because 2 is the only even prime number, and
__________ _______ ____ _________ ______ _______.
_______ _________ _______ _______ ____ _____ _______ _________ ____.
__________ ________ _______ ____ _______ ________ ____ ______ __________ ____ _______ ___.
_____ ________ _____ _______ ____ _____ ________ _______ _________.
________ ______ _____ __________ ______ _____ __________.
_____ ____ _____ _____ _______ __________ _________ _______ _______ _______.
_______ ___ _____ __________ ____ ____ _______ ___ _____.
__________ ________ ____ __________ _________.
____ _________ _________ ___ ________ _______ _____ _______ ___.
___ _____ _________ ______ ______ _____ _________ __________ _________ ____.
_____ ___ ______ __________ ________.
___ _________ _____ _________ ____ _____ ____.
______ ______ ___ _________ ______ ________ _______ _____ _____ ____ ___ ___.
_______ _____ ____ __________ _____ ______ ____ _______ _________ ________.
__________ _____ _________ ______ ______ ____ _____ ___ ____.
______ _________ ___ _________ ____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.