Sie sind auf Seite 1von 1

For Practice

Write a program that identifies the Nth number in the Fibonacci sequence and then adds every third
number of the first fifty numbers in the sequence.

More Practice
ID numbers are vital to identification purposes. As such, protecting such a number becomes an
important factor in protecting your own identity. One such way to do it is through encryption.
Encryption takes data in one form and manipulates it (either into another form or a different value)
that can only be unlocked with a key.

Digital encryption is even more crucial to protecting one's identity. As an ESG111 student you have
been asked to create a program that crudely encrypts a number it is given.

Create a program that accepts a nine digit number as an array (like a student ID number).Keep in
mind that each array element may only hold an integer between 0 and 9. Elements may not be
negative or be greater than 9.

For now, we will assume a sample of 123-45-6789.

The encryption method:

1) Shift all numbers down the array by two. (123-45-6789 --> 891-23-4567)

2) Swap the two numbers in the middle. (891-23-4567 --> 891-32-4567)

3) Subtract each element from 10. (891-32-4567 --> 219-78-6543)

4) Swap the first three numbers with the last three
(219-78-6543 --> 543-78-6219)

5) Generate a single digit random number, called key, and add it to every other number in
the array. Ignore carries and make sure that all numbers remain 1 digit.
(543-78-6219 [key=5] --> 048-73-6714)

6) Use key to subtract that same number from every element unchanged by the previous
step (add 10 to make non-negative if negative).
(048-73-6714 --> 098-23-1764)



Once you've encrypted the number write the original number, key, and new number out to a file.



Your program should:

1) Accept 9 digits and store them in an array.
2) Use the encryption method to encrypt the number.
3) Print the encrypted number.

Das könnte Ihnen auch gefallen