Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Generate Multiples | Functions Returning Arrays and Refactoring Loops
C# Methods and Modular Thinking

Write a method GenerateMultiples that receives number and limit parameters, and returns an array of multiples of a given number up to a specified limit.

  • The method must return an array containing all multiples of number that are less than or equal to limit.
  • If number is zero or greater than limit, the method must return an empty array.
  • The array must contain the multiples in ascending order, starting from number up to the largest multiple not exceeding limit.
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 2
single

single

Challenge: Generate Multiples

Swipe to show menu

Task

Swipe to start coding

Write a method GenerateMultiples that receives number and limit parameters, and returns an array of multiples of a given number up to a specified limit.

  • The method must return an array containing all multiples of number that are less than or equal to limit.
  • If number is zero or greater than limit, the method must return an empty array.
  • The array must contain the multiples in ascending order, starting from number up to the largest multiple not exceeding limit.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 2
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt