Skip to content

Instantly share code, notes, and snippets.

@orekyuu
Created December 6, 2015 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orekyuu/a1ddc8fe0edd39e2a499 to your computer and use it in GitHub Desktop.
Save orekyuu/a1ddc8fe0edd39e2a499 to your computer and use it in GitHub Desktop.
突然のJavaScript
public class Main {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
for(javax.script.ScriptEngineManager manager : new javax.script.ScriptEngineManager[]{new javax.script.ScriptEngineManager()}) {
for(javax.script.ScriptEngine js : new javax.script.ScriptEngine[]{manager.getEngineByName("js")}) {
try {
if(js.eval("function fizzbuzz(a){" +
"if (a % 3 == 0 && a % 5 == 0) {print('FizzBuzz')}" +
"else if(a % 3 == 0) {print('Fizz')}" +
"else if(a % 5 == 0) {print('Buzz')}" +
"else {print(a)}" +
"}") == null){}
if(js.eval("var i = 0") == null) {}
if(js.eval("while(i < 100) { fizzbuzz(i++)}") == null){}
} catch (javax.script.ScriptException e) {
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment