473,464 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

This program won't execute

3 New Member
Expand|Select|Wrap|Line Numbers
  1. public class Twins
  2. {
  3.   public static void main(String args[])
  4.   { 
  5.     int a,b,c;
  6.     a=1;
  7.     b=3;
  8.     for(c=2;c<=97;c++)
  9.     {
  10.       if(a%c==0&&b%c==0)
  11.         System.out.println(a+" and "+b+" are prime twins");
  12.       a++;
  13.       b++; 
  14.     }
  15.   }
  16. }

This was a program to find all the twin prime no.s till 100. It is compiling but when I right click and void main(), nothing happens. Can someone please help me.
Sep 27 '10 #1
3 1281
RamananKalirajan
608 Contributor
The logic you have written for finding a twin prime is wrong. The code has no flaws. It is not in this way you should calculate a twin prime. Twin prime are serious like 3,5;5,7;11,13. You have to change your logic.

Thanks and Regards
Ramanan Kalirajan
Sep 27 '10 #2
Sachu1996
3 New Member
what do you mean the logic is wrong. it is the correct logic.
Sep 27 '10 #3
Oralloy
988 Recognized Expert Contributor
Sachu1996,

Your logic is wrong.

Simply step through the code with a=3 and b=5 to see why it fails.

Good Luck!
Sep 27 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: andthen | last post by:
I read the following in the Thread API: When a Java Virtual Machine starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class)....
3
by: penguinman | last post by:
Its just a hello world program. Compile and build goes with no warning or error. i type ./a.out and the shell just sits there. It doesnt hang but it just sits there with no output. I executed...
11
by: penguinman | last post by:
I type ./a.out and the shell just sits there. It doesnt hang it just sits there looking pretty. I run the program with the ddd option and executed it from ddd...execution window comes up and...
2
by: Merdelus | last post by:
I'm a new visual basic learner, I need some help with this program below: create an application that either sums or averagethe rows or columns of a two dimensional array depending on user...
4
by: switzerland qunatium computer | last post by:
Machine intelligence- can this program be written ?? Machine intelligence- can this program be written ??
1
by: angelcd | last post by:
hi guys, i have this program but it wont compile on DEV C++, it compiles on Borland actually, my compiler say: undefine reference hms (long, long*,long*,long) ld return 1 exit status can...
6
by: khajeddin | last post by:
this program print its own source code without opening the source file. would some one please explain me how does it work ,and what what process takes place in this program???? #include <stdio.h>...
7
by: jamaicaboy | last post by:
This is the code that i need some help with........... #include<iostream.h> #include<iomanip.h> class test { public: void store( int);
12
by: broli | last post by:
#include<stdio.h> #include<stdlib.h> struct point { double x, y, z;
3
by: qwert7465 | last post by:
I wrote this program and took care of most of the errors and when i execute it, it works but something is wrong. It is a store and i put some products in this store and after you made your selection,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.