Advertisement
Guest User

Lotto / BIG WIN

a guest
Mar 24th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.68 KB | None | 0 0
  1.  
  2. rivit = 100000
  3.  
  4. lottonumerot <- data.frame(x1=rep(0, rivit),x2=rep(0, rivit),x3=rep(0, rivit),x4=rep(0, rivit),x5=rep(0, rivit),x6=rep(0, rivit),x7=rep(0, rivit))
  5.  
  6. for (i in 1:rivit){
  7.   arvottu_rivi = sort(sample(1:40, 7, replace=FALSE))
  8.   #print(arvottu_rivi)
  9.   lottonumerot[i,] = rbind(arvottu_rivi)
  10. }
  11.  
  12. oikea_rivi = sort(sample(1:40, 7, replace=FALSE)) #[1] 11 12 16 23 29 33 39
  13. print(oikea_rivi)
  14.  
  15. #View(lottonumerot)
  16. voitot = 0
  17. for (i in 1:rivit){
  18.   if (all(lottonumerot[i,] == oikea_rivi))
  19.     voitot = voitot +1
  20. }
  21. voittoprosentti = round((voitot/rivit)*100, digits = 2)
  22. paste("Rivien määrä: ", rivit)
  23. paste(voitot ,"voittoa,","voittoprosentti",voittoprosentti ,"%" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement