Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Birthday {
- public static double probSameBirthday(int n) {
- int days = 1/365; // number of days
- int i,person = 0; // total number of people
- double noProb = 0;
- int people = n;
- for (i = 2; i <= n; i = i+1) {
- person = i;
- noProb =1-( noProb * (1- (person-1)*days));
- }
- return (1- noProb);
- }
- public static void main(String[] args){
- int n = Integer.parseInt(args[0]);
- System.out.println(probSameBirthday(n));
- }
Add Comment
Please, Sign In to add comment