Diferență între revizuiri ale paginii „DSA Homework 1”
De la WikiLabs
Jump to navigationJump to search (Pagină nouă: = Fractions == Little John is doing math homework and he started writing on a piece of paper a sequence of irreducible fractions of type P/Q, where 1 ≤ P,Q ≤ N, where N is a natu...) |
|||
Linia 1: | Linia 1: | ||
− | = Fractions | + | = Fractions = |
Little John is doing math homework and he started writing on a piece of paper a sequence of irreducible fractions of type P/Q, where 1 ≤ P,Q ≤ N, where N is a natural number chosen by him. For example, for number N = 4, he got the following sequence: | Little John is doing math homework and he started writing on a piece of paper a sequence of irreducible fractions of type P/Q, where 1 ≤ P,Q ≤ N, where N is a natural number chosen by him. For example, for number N = 4, he got the following sequence: |
Versiunea de la data 27 februarie 2014 22:22
Fractions
Little John is doing math homework and he started writing on a piece of paper a sequence of irreducible fractions of type P/Q, where 1 ≤ P,Q ≤ N, where N is a natural number chosen by him. For example, for number N = 4, he got the following sequence:
1/1 1/2 1/3 1/4 2/1 2/3 3/1 3/2 3/4 4/1 4/3
Little John then counted the elements and he saw that for N = 4, there are 11 fractions.
Requirement
Given a natural number N, determine the number of fractions in the sequence constructed with the rules above.
Input Data
Natural number N is read from the keyboard.
Output Data
The program should output one number, representing the number of fractions in the sequence for the given number N.
Restrictions
1 ≤ N ≤ 1.000.000
Examples
Input | Output |
3 | 7 |
4 | 11 |
5 | 19 |
10 | 63 |