7 kyu

Mysterious Singularity Numbers

662 of 1,530mor1nch

Description:

This is a rather simple but interesting kata. Try to solve it using logic. The shortest solution can be fit into one line.

Task

The point is that a natural number N (1 <= N <= 10^9) is given. You need to write a function which finds the number of natural numbers not exceeding N and not divided by any of the numbers [2, 3, 5].


Example

Let's take the number 5 as an example:

  1. 1 - doesn't divide integer by 2, 3, and 5
  2. 2 - divides integer by 2
  3. 3 - divides integer by 3
  4. 4 - divides integer by 2
  5. 5 - divides integer by 5

Answer: 1

because only one number doesn't divide integer by any of 2, 3, 5


Note

Again, try to think of a formula that will shorten your solution and help you pass big tests.

Good luck :)

If you want to solve our problems, they are here: From Singularity Hub Community

Fundamentals
Logic
Mathematics
Arrays
Algorithms
Performance

Stats:

CreatedMar 9, 2023
PublishedMar 9, 2023
Warriors Trained5333
Total Skips172
Total Code Submissions7242
Total Times Completed1530
Python Completions662
JavaScript Completions538
C++ Completions276
TypeScript Completions69
C Completions106
CommonLisp Completions18
RISC-V Completions6
Total Stars100
% of votes with a positive feedback rating80% of 214
Total "Very Satisfied" Votes153
Total "Somewhat Satisfied" Votes37
Total "Not Satisfied" Votes24
Total Rank Assessments12
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • mor1nch Avatar
  • rowcased Avatar
  • uniapi Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • 66  Avatar
  • jpssj Avatar
Ad