- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Golang Program to print all integers between a range that aren't divisible by either 2 or 3
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.
Steps
- 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.
Explanation
- 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.
Example
package main import "fmt" func main(){ for i:=1; i<=50; i++{ if !(i % 2 == 0 || i % 3 == 0){ fmt.Println(i) } } }
Output
1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49
- Related Articles
- 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++
- 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
- Show that the sum of all odd integers between 1 and 1000 which are divisible by 3 is 83667.
- Golang Program to Print Odd Numbers Within a Given Range
- Count numbers in a range that are divisible by all array elements in C++
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Prove that the product of two consecutive positive integers is divisible by 2.
- Program to print all palindromes in a given range in C++
- Prove that one of any three consecutive positive integers must be divisible by 3.
- Golang Program to Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range

Advertisements