fork download
  1. public static void fizzBuzz() {
  2. String str = '';
  3. for (Integer i = 1; i <= 100; i++) {
  4. if ( Math.mod(i, 3) == 0 && Math.mod(i, 5) == 0) {
  5. // System.debug('FizzBuzz');
  6. str +='FizzBuzz'+' ';
  7.  
  8. } else if ( Math.mod(i, 3) == 0) {
  9. str +=' Fizz'+' ';
  10. } else if ( Math.mod(i, 5) == 0) {
  11. str +=' Buzz'+' ';
  12. } else {
  13. str += i+' ';
  14. }
  15. System.debug(' ');
  16.  
  17. }
  18. System.debug('Numbers are -> ' + str +' ');
  19. }
Success #stdin #stdout #stderr 0.01s 8864KB
stdin
Standard input is empty
stdout
Object: nil error: did not understand #static
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #static (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:1: expected expression