ProAnswers.org

Maths Problem

In how many ways can three distinct numbers be chosen from the set {1, 2, …, 100} so that their sum is even?

Sum is even when all the three integers are even or when two are odd and the third is even. So the answer is (50 C 3) + 50*(50 C 2) = 80850.



Here (50 C 3) means combination of 50 objects taken 3 at a time.



[b]This C code on running gives an output(number of ways) as 80850.[/b]



#include 




	 

	int main(){

	    int i, j, k;

	    int count = 0;

	    for(i = 1; i <= 100; i++){

	        for(j = 1; j <= 100; j++){

	            for(k = 1; k <= 100; k++){

	                if((i+j+k)%2==0 && i!=j && j!=k && k!=i)

	                    count++;

	                }

	            }

	        }

	    printf("%d", count/6);//count to be divided by 6(3!)

	    return 0;

	}