java - Function returning a result but gives an error that it doesnt -


this question has answer here:

i try make function checks if number prime or not , eclips gives me error have return result thought do.

public static boolean isprime (int x){     for(int i=2;i<x;i++){         if(x%i==0){             return false;         }     } } 

your logic incomplete:

public static boolean isprime (int x){     for(int i=2;i<x;i++){         if(x%i==0){             return false;         }     }     return true; } 

Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -