- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Let's assume the range is from 0 to 50. We have to print all the integers that aren't divisible by either 2 or 3.

- Use a for loop ranging from 0 to 50.
- Then, use an if statement to check if the number isn't divisible by both 2 and 3.
- Print the numbers satisfying the condition.

- The for loop ranges from 0 to 50.
- The number is divided by 2 and 3.
- If the remainder ≠ 0, the number isn't divisible by either 2 and 3.
- The number satisfying the condition is printed.

package main import "fmt" func main(){ for i:=1; i<=50; i++{ if !(i % 2 == 0 || i % 3 == 0){ fmt.Println(i) } } }

1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49

- Related Questions & Answers
- Python Program to Print all Integers that are not Divisible by Either 2 or 3 and Lie between 1 and 50
- Golang Program to Print all Numbers in a Range Divisible by a Given Number
- Python Program to Print all Numbers in a Range Divisible by a Given Number
- Program to print all the numbers divisible by 3 and 5 in C++
- How to match strings that aren't entirely digits in JavaScript?
- C# program to print all the numbers divisible by 3 and 5 for a given number
- Python program to print all the numbers divisible by 3 and 5 for a given number
- Golang Program to Print Odd Numbers Within a Given Range
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- Count numbers in a range that are divisible by all array elements in C++
- What are some interesting facts about World War 1 that aren't widely known?
- Count all possible groups of size 2 or 3 that have sum as multiple of 3 in C++
- Why aren't variable-length arrays part of the C++ standard?
- Golang Program to Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range
- Find the Numbers that are not divisible by any number in the range [2, 10] using C++

Advertisements