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 - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -