0% found this document useful (0 votes)
171 views6 pages

JS - Mock Exam 1

The document contains instructions for 3 separate math problems: 1) A crooked digit problem that sums the digits of a number repeatedly until the result is <10. 2) A prime triangle problem that prints rows of 1s and 0s indicating whether numbers are prime, based on a given number N. 3) A balanced number problem that sums 3-digit numbers where the middle digit equals the sum of the outer digits, stopping at an unbalanced number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views6 pages

JS - Mock Exam 1

The document contains instructions for 3 separate math problems: 1) A crooked digit problem that sums the digits of a number repeatedly until the result is <10. 2) A prime triangle problem that prints rows of 1s and 0s indicating whether numbers are prime, based on a given number N. 3) A balanced number problem that sums 3-digit numbers where the middle digit equals the sum of the outer digits, stopping at an unbalanced number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Mock Exam 1

Crooked Digits

The crooked digit of a given number N is calculated using the number's digits in a very weird and bendy
algorithm. The algorithm takes the following steps:

Sums the digits of the number N and stores the result back in N.

If the obtained result is bigger than 9, step 1. is repeated, otherwise the algorithm finishes.

The last obtained value of N is the result, calculated by the algorithm.

Input

The input data should be read from the console.

The only line in the input contains a number N, which can be an integer or real number (decimal
fraction), positive or negative.

The input data will always be valid and in the format described. There is no need to check it explicitly.

Output

The output data should be printed on the console.

You must print the calculated crooked digit of the number N on the first and only line of the output.

Constraints

The number N will have no more than 300 digits before and after the decimal point.

The decimal separator will always be the "." symbol.

Sample tests

Input

Output

Input

-7231

Output

4
Input

1020340567.89

Output

Prime Triangle

We know that you love math, so we have prepared a very interesting task, that involves both geometry
and prime numbers.

By a given N number, from which you need to generate a sequence of 1 to N inclusive. For every prime
number in that sequence, you need to print out all the other numbers before it (and the number itself),
whether they are prime or not

Example

Let's say N=10

We have the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

The prime numbers are 1, 2, 3, 5, 7 - 5 prime numbers, so we prive 5 rows

Each row contains all the numbers for 1 to PRIME_NUMBER

Result:

12

123
12345

1234567

Lets make things simpler:

Print 0 if the numbers is not prime

Print 1 if the number is prime

Final result:

11

111

11101

1110101

Input

Read from the standard input

On the single line, find the number N

Output

Print on the standard output

The output should consist of several lines of digits each of which can be either 1 or 0

Without any space between them

Sample tests

Input
10

Output

11

111

11101

1110101

Input

27

Output

11

111

11101

1110101

11101010001

1110101000101

11101010001010001

1110101000101000101

11101010001010001010001

Constraints

The input data will always be valid and in the format described. There is no need to check it explicitly
Balanced Numbers

A balanced number is a 3-digit number whose second digit is equal to the sum of the first and last digit.

Write a program which reads and sums balanced numbers. You should stop when an unbalanced
number is given.

Input

Input data is read from the standard input

Numbers will be given

Each one will be on a separate line

Output

Print to the standard output

Constraints

No more than 1000 numbers will be given

Sample tests

Input

132

123

Output

132

Input

275

693

110

742
Output

1078

You might also like