Tutorial of Odd number

Prerequisite : Basic math
Problem statement summary : You are given a number N.You need to find out how many numbers between 1 to N (inclusive) are ODD.
Solution : We know that if a number is divided by 2 and if you get reminder 1, then we call it an odd number. More formally, if N % 2 = 1, it’s an odd number. Let’s see an example,
If N = 5, all possible number between 1 to N are : 1, 2, 3,4 ,5 and 1, 3 , 5 are odd numbers.
We can see that , no matter which number is N, there is always (N+1)/2 odd numbers.
Time Complexity : O(1)

0 comments

No comments so far...

Information

ID
1041
Difficulty
1
Category
Beginners দেখানোর জন্য ক্লিক করুন
Tags
(None)
# Submissions
63
Accepted
43
Accepted Ratio
68%
Uploaded By