ok ffor the first 50 primes. it relies upon on your language yet. you want one volume that increments for the volume being checked. i'd make this a lengthy as primes can get very massive. then make yet another that checks what percentage primes you've got here across. make a loop some thing like this initiate set primecount to 0 set volume to 4 at the same time as primecount <=40 9 set index to 0 set suitable to authentic at the same time as index<= volume^a million/2 if volume mod index <> 0 then suitable = pretend elseif suitable=authentic end if increment index increment index end at the same time as increment volume end at the same time as some thing like that.. i jsut threw it mutually, yet in case you recognize pseudocode you've the concept. oh and also you in basic words want to research as a lot because the sq. root of the volume and also you dont' verify even numbers numbers dunno what you recommend via vector besides the undeniable fact that
Answers & Comments
Verified answer
Your program in C http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in C# http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in C++ http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in Java http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in JSP http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in Pascal http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in PHP http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in Python http://algoritmosurgentes.com/en/algorithm.php?a=9...
Your program in Visual Basic .Net http://algoritmosurgentes.com/en/algorithm.php?a=9...
Prime Number program:
Demo and script:
Java Program to print Prime Numbers. I hv taken this from
http://www.programming9.com/java/154-java-program-...
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Prime {
public static void main(String args[]) throws IOException {
int n, count, c = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter A Value : ");
n = Integer.parseInt(br.readLine());
System.out.println("Prime Numbers up to " + n);
for (int i = 2; i <= n; i++) {
count = 2;
for (int j = 2; j < i; j++) {
if (i % j == 0)
count++;
}
if (count == 2) {
System.out.print(i + " ");
c++;
}
}
}
}
For C program:
http://www.programming9.com/c-programming/93-c-pro...
ok ffor the first 50 primes. it relies upon on your language yet. you want one volume that increments for the volume being checked. i'd make this a lengthy as primes can get very massive. then make yet another that checks what percentage primes you've got here across. make a loop some thing like this initiate set primecount to 0 set volume to 4 at the same time as primecount <=40 9 set index to 0 set suitable to authentic at the same time as index<= volume^a million/2 if volume mod index <> 0 then suitable = pretend elseif suitable=authentic end if increment index increment index end at the same time as increment volume end at the same time as some thing like that.. i jsut threw it mutually, yet in case you recognize pseudocode you've the concept. oh and also you in basic words want to research as a lot because the sq. root of the volume and also you dont' verify even numbers numbers dunno what you recommend via vector besides the undeniable fact that
success
Hi i am answering your question.
I am not writing any language code. I am writing the algorithm, u can fit it into any language u want.
Algorithm
1. Declare num, divisor, remainder, icount, limit, jcount, numprime as integer
2. Enter the limit, divisor = 2
3. for (icount=2;icount<=limit; icount++ )
4. num= icount, jcount = 1, numprime=0
5. While(jcount <= icount)
{
if(num%jcount)=0 then
{
numprime = numprime +1
}
jcount = jcount + 1
}
6 if (numprime <=2) then
"primenumber is ::" icount
7 next
All the best
regards
[email protected]
increment the number for which you need to generate prime no. and use condition for prime no.
int isprime(unsigned int n)
{
int i;
for(i=2;i<n;i++) if(n%i==0) return 0;
return 1;
}
main()
{
int N, i;
/*To print all prime numbers less than N*/
scanf("%d", &N);
for(i=1;i<=N;i++)
if(isprime(i)) printf("%d\n", i);
}
You can look at this, hopefully it points you in the right direction
http://programmingnotes.freeweq.com/?p=529
#include<iostream.h>
#include<conio.h>
#include<string.h>
void del(char *x,int y,int z)
{
int i;
for(i=0;i<y;i++,x++);
for(i=y;i<z;i++,*x=*(x+1),x++);
}
char flames(int x)
{
int i,j=-1;
char s[]="flames";
while(strlen(s)!=1)
{
for(i=0;i<x;i++)
{
j++;
if(j==strlen(s))
j=0;
}
del(s,j,strlen(s));
j--;
}
return s[0];
}
void res(int x)
{
switch(flames(x))
{
case 'f':cout<<"Friend";
break;
case 'l':cout<<"Lover";
break;
case 'a':cout<<"Affection";
break;
case 'm':cout<<"Marriage";
break;
case 'e':cout<<"Enemy";
break;
case 's':cout<<"Sister";
}
}
void grafix(int x)
{
int i,j;
clrscr();
for(i=0;i<500;i++)
{
for(j=0;j<x;j++)
{
res(i);
cout<<"\t";
}
cout<<"\n";
}
clrscr();
}
void main()
{
char a[20],b[20],c[40];
int i,j,n;
clrscr();
cout<<"\nEnter your name: ";
cin>>a;
cout<<"\nEnter your lover name: ";
cin>>b;
grafix(9);
for(i=0;i<strlen(a);i++)
{
for(j=0;j<strlen(b);j++)
{
if(a[i]==b[j])
{
del(a,i,strlen(a));
del(b,j,strlen(b));
i--;
j--;
}
}
}
strcpy(c,a);
strcat(c,b);
n=strlen(c);
cout<<"\n";
if(n==0)
cout<<"Flames";
else
res(n);
getch();
}