tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,18 @@
|
|||
public class SeqNonSquares {
|
||||
public static int nonsqr(int n) {
|
||||
return n + (int)Math.round(Math.sqrt(n));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// first 22 values (as a list) has no squares:
|
||||
for (int i = 1; i < 23; i++)
|
||||
System.out.print(nonsqr(i) + " ");
|
||||
System.out.println();
|
||||
|
||||
// The following check shows no squares up to one million:
|
||||
for (int i = 1; i < 1000000; i++) {
|
||||
double j = Math.sqrt(nonsqr(i));
|
||||
assert j != Math.floor(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue