# 0031. Primesets

Input file name: | primeset.in |

Output file name: | primeset.out |

Time limit: | 20 s |

Memory limit: | 64 megabytes |

Your task is to count all groups of three natural numbers **a _{1}, a_{2}, a_{3}** in range

**A≤ a**which have the property that any selected two of them are relatively prime. For example, when

_{i}≤ B**A=1**and

**B=2**there are only four groups:

**(1, 1, 1)**,

**(1, 1, 2)**,

**(1, 2, 1)**,

**(2, 1, 1)**.

Input file

The input file consists of two integer numbers **A** and **B**, where **1≤ A≤ B ≤ 30000** and
**B-A≤ 1700**.

Output file

You are to output the number of such groups.

Examples:

primeset.in | primeset.out |
---|---|

1 2 | 4 |

*Source: Petrozavodsk training camp, Summer 2002. Startup contest*

*Author: Andrew Lopatin, Nick Durov*

Discuss Submit a solution

Printable version