Skip to content

Instantly share code, notes, and snippets.

@raupachz
Created November 28, 2018 09:56
Show Gist options
  • Save raupachz/b0771b04895d66b1692abaaa593bedfc to your computer and use it in GitHub Desktop.
Save raupachz/b0771b04895d66b1692abaaa593bedfc to your computer and use it in GitHub Desktop.
The code for my Medium story "Choosing the right amount of memory for your AWS Lambda Function"
public class Prime {
public int nth(int n) {
int p = 2;
for (int i = 0; i < n; ) {
if (prime(p++)) {
i++;
}
}
return --p;
}
boolean prime(int p) {
int n = (p / 2 + 1);
for (int i = 2; i < n; i++) {
if (p % i == 0) {
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment