Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Calculate natural numbers that are divide by 7 & 8 using Java
WhatsApp
Senthilvelan Sambamoorthy
Aug 13
2016
659
0
1
ssvnat.rar
//NATURALS NUMBERS THAT ARE DIVISIBLE BY 7 & 8
import
java.io.*;
class
ssvnat
{
public
static
void
main(String arg[])
throws
IOException
{
int
i,a,b,s=
0
,start,end;
BufferedReader br=
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.println(
"\n\t\t*** NATURALS NUMBERS THAT ARE DIVISIBLE BY 7 & 8 *** \n"
);
System.out.print(
"Enter the number will be started : "
);
start=Integer.parseInt(br.readLine());
System.out.print(
"Enter the number to be end : "
);
end=Integer.parseInt(br.readLine());
for
(i=start;i<=end;i++)
{
a=i%
7
;
b=i%
8
;
if
((a==
0
)&&(b==
0
))
{
System.out.print(
"\t"
+ i);
s=s+i;
}
}
System.out.print(
"\n\nThe Sum of Numbers that are divisible by 7 and 8 : "
+ s);
System.out.println();
}
}
Java
Up Next
Calculate natural numbers that are divide by 7 & 8 using Java