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.
 
 
 
 
 
 
davhojt 1b6b6bee61 docs(get_produects): correct grammar 2 years ago
..
README.md docs(get_produects): correct grammar 2 years ago

README.md

get_products

Instructions

Create a function named get_products that takes a vector of integers, and returns a vector of the products of each index.

You'll need to return the product of every index except the current one.

Example:

For [1,2,3,4], we get:

  • for the number 1 we get 2*3*4 = 24.
  • for the number 3 we get 1*2*4 = 8.

Expected functions

pub fn get_products(arr: Vec<usize>) -> Vec<usize> {

}

Usage

Here is a program to test your function.

use get_products::get_products;

fn main() {
    let arr: Vec<usize> = vec![1, 7, 3, 4];
    let output = get_products(arr);
    println!("{:?}", output);
}

And its output:

$ cargo run
[84, 12, 28, 21]
$

Notions