Giter Site home page Giter Site logo

array-of-multiples's Introduction

Array Of Multiples

Objective :

Create a function that returns an array / list of multiples of num up to length.

Parameters:

  1. num

  2. length

Notes:

  • Notice that num is also included in the returned array / list.

Snippet

Javascript

function arrayOfMultiples(num, length) {
	// write your code here
}

console.log(arrayOfMultiples(7, 5));
// [7, 14, 21, 28, 35]
console.log(arrayOfMultiples(12, 10));
// [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]
console.log(arrayOfMultiples(17, 7));
// [17, 34, 51, 68, 85, 102, 119]
console.log(arrayOfMultiples(630, 14));
// [630, 1260, 1890, 2520, 3150, 3780, 4410,
//  5040, 5670, 6300, 6930, 7560, 8190, 8820]
console.log(arrayOfMultiples(140, 3));
// [140, 280, 420]
console.log(arrayOfMultiples(7, 8));
// [7, 14, 21, 28, 35, 42, 49, 56]
console.log(arrayOfMultiples(11, 21));
// [11, 22, 33, 44, 55, 66, 77, 88, 99, 110,121,
//  132, 143, 154, 165, 176, 187, 198, 209, 220, 231]

Python

def list_of_multiples (num, length):
    # start by overwriting line 9
    pass

print(list_of_multiples(7, 5))
# [7, 14, 21, 28, 35]
print(list_of_multiples(12, 10))
# [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]
print(list_of_multiples(17, 7))
# [17, 34, 51, 68, 85, 102, 119]
print(list_of_multiples(630, 14))
# [630, 1260, 1890, 2520, 3150, 3780, 4410,
#  5040, 5670, 6300, 6930, 7560, 8190, 8820]
print(list_of_multiples(140, 3))
# [140, 280, 420]
print(list_of_multiples(7, 8))
# [7, 14, 21, 28, 35, 42, 49, 56]
print(list_of_multiples(11, 21))
# [11, 22, 33, 44, 55, 66, 77, 88, 99, 110,121,
#  132, 143, 154, 165, 176, 187, 198, 209, 220, 231]

Good Luck!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.