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...) |
|||
(Nu s-au afișat 3 versiuni intermediare efectuate de același utilizator) | |||
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: | ||
Linia 22: | Linia 22: | ||
== Restrictions == | == Restrictions == | ||
− | 1 ≤ N ≤ | + | 1 ≤ N ≤ 100 |
== Examples == | == Examples == | ||
Linia 29: | Linia 29: | ||
|- bgcolor="#ddeeff" align="center" | |- bgcolor="#ddeeff" align="center" | ||
|'''Input''' || '''Output''' | |'''Input''' || '''Output''' | ||
− | |- bgcolor="# | + | |- bgcolor="#ddffdd" align="center" |
| 3 || 7 | | 3 || 7 | ||
|- bgcolor="#ddffdd" align="center" | |- bgcolor="#ddffdd" align="center" |
Versiunea curentă din 28 februarie 2014 13:34
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 ≤ 100
Examples
Input | Output |
3 | 7 |
4 | 11 |
5 | 19 |
10 | 63 |