Hello,i tried to solve the birthday problem with probabilities

and i have a problem,there is an error and i cant find it....

If you are patient plz look my source code and give me your ideas.

#1.This program returns the maximum number of people in a group

when at least 2 of them have a 50% probability to selebrate their birthday the same day.

#3.probality=success trials/number of trials

#4.the array gets random numbers in the interval [1,365] from rand()

I start with a group of 2 people ,the number of the group isnt bigger from 100 people.

#4a. number of people [2,100]

#5.I already solve this problem in a mathimatical form and i know for sure that the probability that at least 2 of them have a 50% to selebrate their birthday the same day when the group is composed by 23

people.

#6.i already isolated the problem but i dont know why this bring me an error )~~:

#7.The error is in the first for loop.If you munually put the number of people i.e people=23 you find the correct probab.(approximately 0.5).With the first loop my program is a total disaster.

Code:`#include<stdio.h>`

#include<stdlib.h>

int main()

{

int people,array[100],number,counter0,counter1,counter2;

float probability,success_trials,limit=0.50,number_of_trials;

printf("Enter the number of trials\n");

scanf("%f",&number_of_trials);

for(probability=0.0,people=2;probability<limit;people++)

{

for (counter0=0;counter0<number_of_trials;counter0++)

{

for (counter1=0;counter1<people;counter1++)

{

number=array[counter1]=rand()%365+1;

/*random numbers in the interval[1,365]*/

for (counter2=0;counter2<counter1;counter2++)

{

if (number==array[counter2])

/*we compare the first array element with the others

and if we find a duplicated number then there

are at least two people with the same birthday*/

{

success_trials++;

counter1=counter2=people;

}

}

}

}

probability=success_trials/number_of_trials;

}

}

#7.The error is in the first for loop.If you munually put the number of people i.e people=23 you find the correct probab.(approximately 0.5).With the first loop my program is a total disaster.put i need it to show the probability for 2,3,4...23 people :)

Code:`#include<stdio.h>`

#include<stdlib.h>

int main()

{

int people=23,array[100],number,counter0,counter1,counter2;

float probability,success_trials,limit=0.50,number_of_trials;

printf("Enter the number of trials\n");

scanf("%f",&number_of_trials);

for (counter0=0;counter0<number_of_trials;counter0++)

{

for (counter1=0;counter1<people;counter1++)

{

number=array[counter1]=rand()%365+1;

/*random numbers in the interval[1,365]*/

for (counter2=0;counter2<counter1;counter2++)

{

if (number==array[counter2])

/*we compare the first array element with the others

and if we find a duplicated number then there

are at least two people with the same birthday*/

{

success_trials++;

counter1=counter2=people;

}

}

}

}

probability=success_trials/number_of_trials;

printff("%f\n",probability);

return 0;

}