<commit_before>/* Finding the 10001st prime number 
 *
 * Answer: 104743
 * Project Euler: 7 */

/* Includes */
#include <stdio.h>

/* Definitions */
#define MAX 10001

/* Prototypes */
int isprime(int s);
int main();

int main()
{
        int primec = 0; int last;

        for(int i = 0; primec != MAX; i++){
                if (isprime(i)){
                        primec++;
                }

                last = i;
        }

        printf("%d\n", last);

}
       
       
/* Detects whether int is prime */
int isprime(int s)
{
        int isprime = 0; /* False */

        for(int i = 2; i < s+1; i++){
                if(i == s){
                        isprime = 1; /* True */
                        break; 
                }

                if (s % i == 0){
                        break;
                }
        }

        return isprime;
}
                <commit_msg>Algorithm way better<commit_after>/* Finding the 10001st prime number 
 *
 * Answer: 104743
 * Project Euler: 7 */

/* Includes */
#include <stdio.h>
#include <math.h>

/* Definitions */
#define MAX 10001

/* Prototypes */
int isprime(int s);
int main();

int main()
{
        int primec = 0; int last;

        for(int i = 0; primec != MAX; i++){
                if (isprime(i)){
                        primec++;
                }

                last = i;
        }

        printf("%d\n", last);

}


/* This is the bottleneck. Takes ages */
int isprime(int s)
{
        int isprime = 0; /* False */
        int top = (int) round(sqrt(s))+1;

        if (s == 1){
                return 0;
        }

        if (s == 2){
                return 1;
        }

        for(int i = 2; i < top +1 ; i++){
                if(i == top){
                        isprime = 1; /* True */
                        break; 
                }

                if (s % i == 0){
                        break;
                }
        }

        return isprime;
}
{'fraction_non_alphanumeric': 0.13697219361483007, 'fraction_numerical': 0.02729145211122554, 'mean_word_length': 1.0113871635610765, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6150275', 'n_tokens_mistral': 663, 'n_tokens_neox': 567, 'n_words': 170}