Diferență între revizuiri ale paginii „DSA Homework 1”
De la WikiLabs
Jump to navigationJump to searchLinia 27: | Linia 27: | ||
{| class="wikitable" | {| class="wikitable" | ||
− | |- bgcolor="# | + | |- bgcolor="#ddffdd" align="center" |
|'''Input''' || '''Output''' | |'''Input''' || '''Output''' | ||
− | |- bgcolor="# | + | |- bgcolor="#ddffdd" align="center" |
| 3 || 7 | | 3 || 7 | ||
|- bgcolor="#ddffdd" align="center" | |- bgcolor="#ddffdd" align="center" |
Versiunea de la data 27 februarie 2014 22:29
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 |