Write two generators: walk an array in circular jumps, and yield factorials as BigInt

easyAbout 20 minutesUpdated CodingProgeneratorsiteratorsbigintmodulo
Not solved

Share this question

Problem

Generators can pause, hand back a value, and receive one on the way back in. Write two of them.

const gen = circular([10, 20, 30, 40, 50], 0);
gen.next().value;    // 10
gen.next(1).value;   // 20
gen.next(2).value;   // 40
gen.next(-3).value;  // 10
gen.next(7).value;   // 30  (7 steps from index 0 lands on index 2)

Ref. UR-1424 · © UIRound · uiround.com/questions/write-two-generators-walk-an-array-in-circular-jumps-and-yield-factorials-as-bigint

Stuck? Take a hint

Try it in the editor

Run your code as often as you like. Submitting it to the full test suite is part of Pro.

Private, and saved in this browser as you type. All your notes are on My lists.

Every question and answer7 days, one payment