class HelloWorld {
public static void main
(String []args
) { int numero = 123456;
long time
= System.
nanoTime(); for (int i = 0; i < 10000000; i++) {
int resultado = 0;
while (numero != 0) {
numero /= 10;
resultado += numero % 10;
}
}
for (int i = 0; i < 10000000; i++) {
int resultado = 0;
for (char digito : texto.toCharArray()) {
resultado
= resultado
+ Character.
getNumericValue(digito
); }
}
}
}
Y2xhc3MgSGVsbG9Xb3JsZCB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgW11hcmdzKSB7CiAgICAgICAgaW50IG51bWVybyA9IDEyMzQ1NjsKICAgICAgICBsb25nIHRpbWUgPSBTeXN0ZW0ubmFub1RpbWUoKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDEwMDAwMDAwOyBpKyspIHsKICAgICAgICAgICAgaW50IHJlc3VsdGFkbyA9IDA7CiAgICAgICAgICAgIHdoaWxlIChudW1lcm8gIT0gMCkgewogICAgICAgICAgICAgICAgbnVtZXJvIC89IDEwOwogICAgICAgICAgICAgICAgcmVzdWx0YWRvICs9IG51bWVybyAlIDEwOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigoU3lzdGVtLm5hbm9UaW1lKCkgLSB0aW1lKSArICJucyIpOwogICAgICAgIHRpbWUgPSBTeXN0ZW0ubmFub1RpbWUoKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDEwMDAwMDAwOyBpKyspIHsKICAgICAgICAgICAgU3RyaW5nIHRleHRvID0gU3RyaW5nLnZhbHVlT2YobnVtZXJvKTsKICAgICAgICAgICAgaW50IHJlc3VsdGFkbyA9IDA7CiAgICAgICAgICAgIGZvciAoY2hhciBkaWdpdG8gOiB0ZXh0by50b0NoYXJBcnJheSgpKSB7CiAgICAgICAgICAgICAgICByZXN1bHRhZG8gPSByZXN1bHRhZG8gKyBDaGFyYWN0ZXIuZ2V0TnVtZXJpY1ZhbHVlKGRpZ2l0byk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKChTeXN0ZW0ubmFub1RpbWUoKSAtIHRpbWUpICsgIm5zIik7CiAgICB9Cn0=