Does R code match for what is being asked? Question Let U1,....,Un be i.i.d. Unif(0,1), and X = max(U1,...,Un).
(a) What is the PDF of X?
(b) What is EX?
(c) Use simulations in R (the statistical programming language) to numerically estimate EX.
My solution
So, the formula I got for EX is $ \frac{n}{n+1}$. I wrote an R script to estimate the value of EX, which I have shown below:
simfunc2 <- function(sims, n) {
  outcome <-rep(0,sims)
  for(i in 1:sims){
    x <-runif(n,0,1)
    outcome[i] <-max(x)
  }
  res <- mean(outcome)
  return(res)
}

so the answer for expectation I am getting using the simulation in R is 0.9903 while the answer I am getting using the mean formula is 0.9900.
 A: Your code looks perfectly fine post edits.  It's clear and well articulated, good job.
In the interests of giving you a bit more content than just a "Yup, good to go", I re-wrote your sampler in more idiomatic R
simulate <- function(n_sims, n_samples) {
    x <- matrix(runif(n_sims * n_samples, 0, 1), nrow = n_sims)
    maxs <- apply(x, 1, max)
    mean(maxs)
}

To be clear, I don't think there's anything wrong with the way you expressed the algorithm in your code, but this is what you can expect to see from experienced R programmers.
whuber comments:

I do recommend returning the full set of simulations so they can be compared to a theoretical value, plotted, etc. 

The way you would accomplish this in R is to return a list object
simulate <- function(n_sims, n_samples) {
    x <- matrix(runif(n_sims*n_samples, 0, 1), nrow = n_sims)
    maxs <- apply(x, 1, max)
    m <- mean(maxs)
    s <- sd(maxs)
    list(mean = m, sd = s, sims = x)
}

Then you can pull out the various attributes using the $ notation
> sim <- simulate(1000, 2)
> sim$mean
[1] 0.6605091
> sim$sd
[1] 0.2340585

