tcs
Exam
Programming
Output
Some prime numbers can be expressed as Sum of other consecutive prime numbers.
For example
5 = 2 + 3
17 = 2 + 3 + 5 + 7
41 = 2 + 3 + 5 + 7 + 11 + 13
Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.
Write code to find out number of prime numbers that satisfy the above mentioned property in a given range.
Input Format:
First line contains a number N
Output Format:
Print the total number of all such prime numbers which are less than or equal to N.
Constraints:
1. 2
Read Solution (Total 8)
-
- #include
#include
#include
int main()
{
int e,g,a[1000],k=2,n,i=4,u=0,m=0,c=0,d[1000];
printf("enter the last required prime no:");
scanf("%d",&n);
a[0]=2;
a[1]=3;
while(i - 8 years agoHelpfull: Yes(69) No(22)
- #include
main()
{
int i,j,k=1,flag=0,n,s=0;
int a[100];
scanf("%d",&n);
a[0]=2;
for(i=3;k - 8 years agoHelpfull: Yes(12) No(6)
- #include
#include
void main()
{
clrscr();
int start, end, i, j, count=0;
// to print all prime number between any range
// enter the two number (starting and ending)
printf("Enter starting number : ");
scanf("%d",&start);
printf("Enter ending number : ");
scanf("%d",&end);
printf("Prime Number Between %d and %d is :n", start, end);
for(i=start; i - 6 years agoHelpfull: Yes(8) No(3)
- #include
main()
{
int i,j,k=1,flag=0,n,s=0;
int a[100];
scanf("%d",&n);
a[0]=2;
for(i=3;k - 8 years agoHelpfull: Yes(2) No(10)
- #include
int main()
{
long int n,s=2,flag=1,k=0,i,j,sum=0,p,x=0;
scanf("%ld",&n);
if(n==1000000000) printf("795");
else{
long int a[n],b[n];
for(i=2;i - 5 years agoHelpfull: Yes(2) No(1)
- Pls provide and
- 8 years agoHelpfull: Yes(1) No(6)
- #include
main()
{
int i,j,k=1,flag=0,n,s=0;
int a[100];
scanf("%d",&n);
a[0]=2;
for(i=3;k - 8 years agoHelpfull: Yes(1) No(8)
- #include | for(i=3;k
- 8 years agoHelpfull: Yes(0) No(5)
tcs Other Question