PAMunb / JimpleFramework

A Rascal implementation of the Jimple framework.
13 stars 5 forks source link

Error running a specific algorithm #37

Open mateusluizfb opened 3 years ago

mateusluizfb commented 3 years ago

When running this java code:

// Source: https://www.w3resource.com/java-exercises/math/java-math-exercise-20.php
public class GeneratePrimes {
    public static int [] generatePrimes(int num) {
        boolean[] temp = new boolean[num + 1];
        for (int i = 2; i * i <= num; i++) {
            if (!temp [i]) {
                for (int j = i; i * j <= num; j++) {
                    temp [i*j] = true;
                }
            }
        }
        int prime_nums = 0;
        for (int i = 2; i <= num; i++) {
            if (!temp [i]) prime_nums++;
        }
        int [] all_primes = new int [prime_nums];
        int index = 0; 
        for (int i = 2; i <= num; i++) {
            if (!temp [i]) all_primes [index++] = i;
        }
        return all_primes;
    }
}

This error was raised:

Screen Shot 2021-03-11 at 19 58 25