Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Formula for x with this pattern?

x is a number from 1 to 10.

What could be the formula for x with this pattern?

x = 1 -> output 0
x = 2 -> output 1
x = 3 -> output 2
x = 4 -> output 3
x = 5 -> output 4
x = 6 -> output 0
x = 7 -> output 1
x = 8 -> output 2
x = 9 -> output 3
x = 10 -> output 4

I came up with

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

x % 5 - 1

but does not work when x = 5 or x = 10

>Solution :

You were close, just move the subtraction operation before the modulo operation

(x - 1) % 5
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading