Given is an integer N.Simon chooses an integer 'a' from the positive integers not greater than 'N' with equal probability. Find the probability that 'a' is odd.
#include <stdio.h>
int main()
{int n;
float t;
scanf ("%d",&n);
if(n%2==0)
printf("%d",(n/2)/n);
else{
t=(n/2);
t=(t+1)/n;
printf("%.9f",t);}
return 0;}
Comments
Post a Comment