x is a double precision vector containing numbers both smaller and bigger than 1:

```
x <- c(1, 2, 3, 0.1, 0.02, 0.003)

```

If an element in x is smaller than one, I would like to multipy that element by 10 until it is bigger than one; if the element is already bigger than one, it should remain unchanged. The result should be a double precision vector again:

```
(1, 2, 3, 1, 2, 3)

```

I feel like this should be very simple, but the solution eludes me. Here is what I did so far. I defined the function times\_ten that does the operation described above:

```
times_ten <- function(x) {
  while (x < 1) {
    x <- x * 10
  }
}

```

Then I apply this function to the vector x:

```
y <- sapply(c(1, 2, 3, 0.1, 0.02, 0.003), function(x) times_ten(x))

```

But now y is a list and no longer a double. Even worse, all values in y are now NULL.

Do I have to change the function, and if so, how? Or is there a better approach entirely?