Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use this link to run code against test cases: https: https://docs.google.com/document/d/1R6DYBR_9zzgob4IHxRyrUKRGPBQFiUUthcYt0L74CYY/edit?usp=sharing Predict Stark's Numbers HHackerRank Stark is studying a random number generator that someone else

Use this link to run code against test cases: https: https://docs.google.com/document/d/1R6DYBR_9zzgob4IHxRyrUKRGPBQFiUUthcYt0L74CYY/edit?usp=sharing

image text in transcribedimage text in transcribed

Predict Stark's Numbers HHackerRank Stark is studying a random number generator that someone else has built in the shape of a physical black box. On it, there is a small screen, a keypad, and a big red button. While it is in "Standby mode", he configures it with 4 positive numbers: a, b. c and d (which he enters using the keypad). Once configured, he switches it to "Operating" mode, and it displays a number on its screen, which is meant to be its output. Each time he presses the button, the number on the screen changes to a seemingly unpredictable one. After some studying though, he notices the following facts: when switched to "Operating" mode, the initial number output is always c if the current number output is z, the next number output will be (az b) mod d Stark wants to know what the output would be if the button were pushed n times, for some given n. Can you write a program to help Stark predict this? Input Format A line containing the integers: n cabd Constraints 13 n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions