# Homework Help: Discrete Math Questions

1. Oct 28, 2007

### bassplayer142

I have two problems that I am having a little trouble with. Thanks in advance.

1. The problem statement, all variables and given/known data
Count the number of times the following algorithm prints "Hello", then find the "best" big-oh approximation for the number of print statements in the algorithm.

For i=1 to n
Begin
Print "Hello"
For j=1 to i
Print "Hello"
End
End

3. The attempt at a solution

I found that
at n=1, hello 2 times
at n=2, hello 3 times
at n=3, hello 4 times
at n=4, hello 5 times
at n=5, hello 6 times...

I tried to find an equation that would follow this pattern but all the ones I could think of would work for a few times then it would go off. Is there an equation or something I can plug into this to figure it out? Don't worry about the Big-oh approximation as I can do that myself. I just need to figure out the formula. Thanks

This is the second problem.

1. The problem statement, all variables and given/known data

How many different functions are there from {1,2,3,4} to {1,2,3}?

2. Relevant equations

C(n,r)
P(n,r)

3. The attempt at a solution

I'm not sure what to do in this problem or what it really is asking for. I think it might have something to do with subsets of {1,2,3} but I'm not sure. Any help is great.