/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
int valorInicial = 3;
int n = 7;
ArrayList<Integer> lista = new ArrayList<>();
// usando math
for(int i = valorInicial; i <= n; i++){
lista.
add((int)Math.
pow(i,
2)); }
System.
out.
print("Usando Math: "); }
//simbolico, apenas para reaproveitar o mesmo ArrayList
lista.clear();
//sem usar math
for(int i = valorInicial; i <= n; i++){
lista.add(i*i);
}
System.
out.
print("Sem usar Math: "); }
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludCB2YWxvckluaWNpYWwgPSAzOwoJCWludCBuID0gNzsKCQlBcnJheUxpc3Q8SW50ZWdlcj4gbGlzdGEgPSBuZXcgQXJyYXlMaXN0PD4oKTsKCQkvLyB1c2FuZG8gbWF0aAoJCWZvcihpbnQgaSA9IHZhbG9ySW5pY2lhbDsgaSA8PSBuOyBpKyspewoJCQlsaXN0YS5hZGQoKGludClNYXRoLnBvdyhpLDIpKTsKCQl9CgkJU3lzdGVtLm91dC5wcmludCgiVXNhbmRvIE1hdGg6ICIpOwoJCWZvcihJbnRlZ2VyIG51bSA6IGxpc3RhKXsKCQkJU3lzdGVtLm91dC5wcmludChudW0gKyAiICIpOwoJCX0KCQkvL3NpbWJvbGljbywgYXBlbmFzIHBhcmEgcmVhcHJvdmVpdG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