Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nRand = 10000000;
- hit = 0;
- for i = 1:nRand
- x = rand();
- y = rand();
- z = rand();
- if(x^2 + y^2 + z^2 < 1)
- hit = hit + 1;
- end
- end
- (hit/nRand)* 8 * (3/4);
- %%
- nRand = 10000000;
- hit = 0;
- for i = 1:nRand
- heads = 0;
- for b = 1:5
- if(rand() > .5)
- heads = heads + 1;
- end
- end
- if(heads == 3)
- hit = hit + 1;
- end
- end
- (hit/nRand);
Add Comment
Please, Sign In to add comment