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
Post a Comment