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
srujith chintha 4srujith chintha 4 

Print all of the positive integers from 1 to 100.

  • Print out all positive integers from 1 to 100, inclusive and in order.
  • Print messages to standard output, matching the Sample Output below.
  • In the output, state whether each integer is ‘odd’ or ‘even’ in the output.
  • If the number is divisible by three, instead of stating that the number is odd or even, state that the number is ‘divisible by three’.
  • If the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is ‘divisible by two and three’.
  • Design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic.
  • Print out all positive integers from 1 to 100, inclusive and in order.
  • Print messages to standard output, matching the Sample Output below.
  • In the output, state whether each integer is ‘odd’ or ‘even’ in the output.
  • If the number is divisible by three, instead of stating that the number is odd or even, state that the number is ‘divisible by three’.
  • If the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is ‘divisible by two and three’.
  • Design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic.
  • Print out all positive integers from 1 to 100, inclusive and in order.
  • Print messages to standard output, matching the Sample Output below.
  • In the output, state whether each integer is ‘odd’ or ‘even’ in the output.
  • If the number is divisible by three, instead of stating that the number is odd or even, state that the number is ‘divisible by three’.
  • If the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is ‘divisible by two and three’.
  • Design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic.
  • Print out all positive integers from 1 to 100, inclusive and in order.
  • Print messages to standard output, matching the Sample Output below.
  • In the output, state whether each integer is ‘odd’ or ‘even’ in the output.
  • If the number is divisible by three, instead of stating that the number is odd or even, state that the number is ‘divisible by three’.
  • If the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is ‘divisible by two and three’.
  • Design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic.
PriyaPriya (Salesforce Developers) 
Hey Srujith,

Please try below :- 
for(Integer i=1;i<=100;i++){
    Integer result = math.mod(i,2);
    if(result == 0){
        System.debug(i);
    }
}


Please mark it as the best answer if it resolves your issue.

For more solution, refer this :-
https://developer.salesforce.com/forums/?id=9062I000000gCmpQAE


Note :-  The developer community recommends providing any attempts/code you've started, any errors you're getting, or where exactly you're struggling in achieving this while posting a question.

Thanks