We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
interfacePerformOperation{booleancheck(inta);}classMyMath{publicstaticbooleanchecker(PerformOperationp,intnum){returnp.check(num);}// Write your code herePerformOperationisOdd(){return(n)->n%2==0?false:true;}PerformOperationisPrime(){return(n)->{if(n<=1)returnfalse;if(n==2||n==3)returntrue;if(n%2==0||n%3==0)returnfalse;for(inti=5;i<=Math.sqrt(n);i=i+6){if(n%i==0||n%(i+2)==0)returnfalse;}returntrue;};}PerformOperationisPalindrome(){return(n)->{Stringstr=String.valueOf(n);intlen=str.length();for(inti=0;i<len/2;i++){if(str.charAt(i)!=str.charAt(len-i-1))returnfalse;}returntrue;};}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Lambda Expressions
You are viewing a single comment's thread. Return to all comments →