id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav.gupta@mq.edu.au arrays > patternedArray
prev  |  next  |  chance

First, solve https://codingbat.com/prob/p279839 Define a function that when passed three integers (say a, b, n), returns an array in an arithmetic progression such that it contains n items, the first (if any) being a, the second (if any) being b. The subsequent items can be worked out from the information provided. Return an empty array if n <= 0.


patternedArray(1, 2, 0) → []
patternedArray(1, 2, -1) → []
patternedArray(2, 4, 5) → [2, 4, 6, 8, 10]

...Save, Compile, Run (ctrl-enter)

int[] patternedArray(int a, int b, int n) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 4 Post-solution available

Copyright Nick Parlante 2017 - privacy