function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rajasekhar RSRajasekhar RS 

Integer

Given an integer, n, perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of 2 to 5 , print Not Weird
If n is even and in the inclusive range of 6 to 20 , print Weird
If n is even and greater than 20 , print Not Weird
Arun Kumar 1141Arun Kumar 1141
Hi Rajasekhar RS,
public class EvenOdd {
    public static void evenOddMethod(integer num){
        if(math.mod(num,2)==0){
            if(num>=2 && num<=5){
                system.debug(' not weird');
            }
            else if (num>=6 && num<=20){
                system.debug(' weird');
            }
            else{
                system.debug('not weird');
            }
        }
        else{
            system.debug('weird');
        }
       
    }
}
Hope this helps you.
Thanks!
 
Rajasekhar RSRajasekhar RS
I want only in devloper console
Rajasekhar RSRajasekhar RS
I want only anonymous window
SubratSubrat (Salesforce Developers) 
Hello Rajasekhar ,

You can try like this :

User-added image
After this , click on execute and Debug only for the output.

If this helps , please mark this as Best Answer.
Thank you.