- 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 Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range
Steps
- Take in the upper and lower range and store them in separate variables.
- Use a for loop which ranges from the lower range to the upper range.
- Find the numbers which are divisible by both 5 and 7.
- Print those numbers.
Case 1 Enter the lower range: 1 Enter the upper range: 100 35 70 | Case 2 Enter the lower range: 400 Enter the upper range: 700 420 455 490 525 560 595 630 665 700 |
Explanation
- User must enter the upper range limit and the lower range limit.
- The for loop ranges from the lower limit to the upper limit.
- The value of i ranges from the lower limit to the upper limit.
- Whenever the remainder of i divided by 5 and 7 is equal to 0, print i.
Example
package main import "fmt" func main(){ var upperLimit, lowerLimit int fmt.Printf("Enter lower limit for the range: ") fmt.Scanf("%d", &lowerLimit) fmt.Printf("Enter upper limit for the range: ") fmt.Scanf("%d", &upperLimit) for i:=lowerLimit; i<=upperLimit; i++{ if i%7 == 0 && i%5 == 0{ fmt.Println(i) } } }
Output
Enter lower limit for the range: 1 Enter upper limit for the range: 100 35 70
- Related Articles
- 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
- Find the number of numbers which are divisible by $7$ between $100$ and $1000$.
- Write a Golang program to find prime numbers in a given range
- Find the total two-digit numbers which are divisible by $5$.
- Count the numbers divisible by ‘M’ in a given range in C++
- Golang Program to Print Odd Numbers Within a Given Range
- 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
- Program to find bitwise AND of range of numbers in given range in Python
- Find the number of natural numbers between 101 and 999 which are divisible by both 2 and 5.
- Python Program to Find All Numbers which are Odd and Palindromes Between a Range of Numbers
- Sum of first N natural numbers which are divisible by 2 and 7 in C++
- How to find numbers that are divisible by a certain number for a range of values in R?
- Count numbers in range 1 to N which are divisible by X but not by Y in C++

Advertisements