Guest User

Untitled

a guest
Oct 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public class Birthday {
  2. public static double probSameBirthday(int n) {
  3. int days = 1/365; // number of days
  4. int i,person = 0; // total number of people
  5. double noProb = 0;
  6. int people = n;
  7. for (i = 2; i <= n; i = i+1) {
  8. person = i;
  9. noProb =1-( noProb * (1- (person-1)*days));
  10. }
  11. return (1- noProb);
  12.  
  13. }
  14.  
  15.  
  16.  
  17. public static void main(String[] args){
  18. int n = Integer.parseInt(args[0]);
  19. System.out.println(probSameBirthday(n));
  20.  
  21. }
Add Comment
Please, Sign In to add comment