Special numbers

2.9

32 votes
Basic Programming, Math, Number Theory
Problem

A natural number is special if it consists of only digits 4 and 7. Find the number of pairs of сoprime special numbers (x, y) such that 1xyN

Input format

The first line contains an integer N (1N109).

Output format

Print a single number denoting the answer to the problem.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Clarification: https://en.wikipedia.org/wiki/Coprime_integers

Answer = 1 because 4 and 7 10 and gcd(4,7) = 1

Editor Image

?