Oct. 26, 2023, 8:14 p.m. | Lluís Josep Martínez

DEV Community dev.to

Just for fun, I asked chatGPT to give me a Java implementation of the sieve of Eratosthenes to find the first 100 prime numbers.

It gave me this:



public class SieveOfEratosthenes {
public static void main(String[] args) {
int n = 100; // Change this to the desired limit to find prime numbers up to n.
boolean[] isPrime = new boolean[n + 1];

Arrays.fill(isPrime, true); …

change chatgpt cleancode code fun implementation java making numbers prime public string

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Sr. BI Analyst

@ AkzoNobel | Pune, IN