mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
561 B
35 lines
561 B
4 years ago
|
## stars
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Write a function named `stars` that takes a number as
|
||
|
parameter and returns a string of stars (asterisks) 2^n long (2 to the nth power).
|
||
|
|
||
|
### Expected functions
|
||
|
|
||
|
```rust
|
||
|
fn stars(n: u32) -> String {}
|
||
|
```
|
||
|
|
||
|
### Usage
|
||
|
|
||
|
Here is a program to test your function.
|
||
|
|
||
|
```rust
|
||
|
fn main() {
|
||
|
println!("{}", stars(1));
|
||
|
println!("{}", stars(4));
|
||
|
println!("{}", stars(5));
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/[[ROOT]]/test$ cargo run
|
||
|
**
|
||
|
****************
|
||
|
********************************
|
||
|
student@ubuntu:~/[[ROOT]]/test$
|
||
|
```
|