Matlab Help, for loop problem

  • Thread starter AASaunders
  • Start date
  • #1
Hi guys, I have been given a problem to complete, but at the moment my progress has been minimal.

A gambler has £1 to gamble, he plays a game in which the probability of winning and losing are equal. If he wins he gains a pound, and loses a pound if he does not win. He starts with £1 and must stop once he has no money remaining. He has a goal of £100, if he achieve this he will stop and consider himself to have beat the casino. What is the probability of the gambler winning?
I have only had two classes on using Matlab since September, thus I am not very experienced.

To complete this problem I know I need to use nested For loops but I just don't know where to start, so any guidance would be appreciated very much.
 

Answers and Replies

  • #2
90
2
Hello AASaunders,

I would say it would be easier with 2 nested "while" loops.

The outer one to make sure you get a few wins, the inner one to break free of the game once you lose or win.

J.
 

Related Threads on Matlab Help, for loop problem

Replies
4
Views
1K
  • Last Post
Replies
15
Views
5K
  • Last Post
Replies
3
Views
21K
  • Last Post
Replies
8
Views
1K
Replies
1
Views
1K
  • Last Post
Replies
22
Views
5K
Replies
1
Views
5K
  • Last Post
Replies
1
Views
2K
Replies
1
Views
3K
  • Last Post
Replies
0
Views
5K
Top