c# - not all paths return a value in anonymous method -


i trying create method checks if number abundant (the sum of proper divisors greater number itself), error @ 1.toinc(28123, 1) line of code says: "not code paths return value in anonymous method of type system.func<int,bool>". believe referring isabundant method. in isabundant doesn't return value?

public void solve () {     //check if number abundant -> number < sum of proper divisors. memoize     func<int, bool> isabundant = x =>     {         return x < properdivisors (x).select(x => x).sum () && x >= 0;     };          isabundant = isabundant.memoize ();          //make sequence of these numbers readability         var seq = 12.toinc (28123, 1).takewhile (x => isabundant (x));                      // take numbers between 13 , 28123 take while (from 12 number / 2 sequence) check if number - item sequence isn't abundant         1.toinc (28123, 1).takewhile (x => {             foreach (var in seq){                 if (i < x/2){                     if (isabundant (x - i))                         return false;                     else                         return true;                 }             }         })         // sum         .sum ().display ();     } } 

this referring lambda here:

.takewhile (x => {         foreach (var in seq){             if (i < x/2){                 if (isabundant (x - i))                     return false;                 else                     return true;             }         }          // if there no elements in seq, you'll reach here, , never return value!         // add here, ie:         return false;     }) 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -