Pratian technologies
Programming and Technical
Programming
Puzzles
2, 3, 5, 11, 23, 29, 41, 53, 83, 89, 113, 131.......
Read Solution (Total 30)
-
- the above sries is sophie series... if x is a prime number, then we will check for (2x+1). if 2x+1 is also a prime number then we will print x.. so this way we check for n number of terms and those number which satisfy the condition we will print those number. below is the code for 200 number of terms.
class SophieSeries{
class SophieSeries() {} // constructor
private static boolean isPrime(int p){ // checking prime no. or not
for(int i=2; i - 9 years agoHelpfull: Yes(146) No(21)
- //K. Jagannadham MCA (kjagancool@gmail.com, 8985363833)
import java.io.*;
public class PrimeNum{
public static void main(String[] args)throws IOException{
int i,j,n,c,p=0,d;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
n=Integer.parseInt(br.readLine());
for(i=1;i - 9 years agoHelpfull: Yes(25) No(11)
- /*
Write a program to print following sequence.
2,3,5,11,23,29,41,53,83,89...
*/
import java.util.Scanner;
class Series3{
public static boolean isPrime(int number){
int i;
for(i = 2; i - 8 years agoHelpfull: Yes(19) No(6)
- import java.util.Scanner;
public class Sophie_Germain_Prime {
static int n,p,cnt,term;
private static Scanner input;
static void Input(){
input = new Scanner(System.in);
System.out.println("Enter the term upto : ");
term = input.nextInt();
}
static boolean Check_Prime(int i){
cnt = 0;
for(int j=1;j - 9 years agoHelpfull: Yes(18) No(3)
- In C we do like this.
#include
int main()
{
int i,j,n=150,flag=0,count=0,k=0,a;
printf("2t");
for(i=3;i - 8 years agoHelpfull: Yes(14) No(2)
- 2n+1
For n=3 2*3+1=7 is a prime number but not given in series
Y? - 9 years agoHelpfull: Yes(12) No(4)
- //correct code
import java.util.Scanner;
/**
*
* @author AndroidFarook
*/
public class Writtenexample1 {
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter limit:");
int n=in.nextInt();
int count;
for(int i=1;i - 7 years agoHelpfull: Yes(10) No(5)
- these are the sophie prime numbers i.e.
if "x" is a prime no. then "2x+1" is also a prime no.
eg:- x=2 , 2x+1 =2(2)+1=4+1=5 also a prime number.
Similarly, this is true for all the given numbers...!! - 9 years agoHelpfull: Yes(7) No(9)
- #include
int check(int,int);
int check1(int,int);
int main()
{
int num=100;
int flag=0;
for(int i=2;i - 9 years agoHelpfull: Yes(7) No(4)
- import java.util.Scanner;
public class HelloWorld{
static int checkprime(int a ){
int flag=0;
int set=0;
for(int i=2;i - 8 years agoHelpfull: Yes(6) No(2)
- //////////////////////2 3 5 11 23 29 41 53 83 89
public class Series {
public static void main(String[] args) {
int i;
for(i=2;i - 7 years agoHelpfull: Yes(4) No(1)
- These Series are Additive primes...... means sum of digits should be prime. i.e 11:1+1=2, 23:2+3=5, 29:2+9=11 as so on......
- 9 years agoHelpfull: Yes(3) No(19)
- import java.util.Scanner;
public class Series3
{
public static void main(String args [])
{
Scanner dc =new Scanner(System.in);
System.out.println("plz enter any number ");
int n=dc.nextInt();
int i;
for(i=1;i - 8 years agoHelpfull: Yes(3) No(0)
- class Prime{
static int check,check1;
public static void main(String[]args){
int n=Integer.parseInt(args[0]);
for(int i=2;i - 9 years agoHelpfull: Yes(2) No(5)
- the above sries is sophie series... if x is a prime number, then we will check for (2x+1). if 2x+1 is also a prime number then we will print x.
public class Pratian6 {
public static void main(String[] args) {
int i, num, b = 0;
for (i = 2; i = 1; num--) {
if (i % num == 0 || (2 * i + 1) % num == 0) {
counter = counter + 1;
}
}
if (counter == 2) {
System.out.println(i);
}
}
}
} - 8 years agoHelpfull: Yes(2) No(11)
- import java.util.Scanner;
public class Ser {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
for(int i=2;i - 7 years agoHelpfull: Yes(2) No(0)
- public class Pratian7 {
public static void main(String[] args) {
int i, num;
for (i = 2; i = 1; num--) {
if (i%num==0 ||(2 * i + 1)% num == 0) {
counter = counter + 1;
}
}
if (counter == 2) {
System.out.print(i+" ");
}
}
}
} - 8 years agoHelpfull: Yes(1) No(0)
- import java.util.Scanner;
public class SophieSeries {
static boolean isPrime(int a)
{
int count = 0;
for(int j = 1 ; j - 8 years agoHelpfull: Yes(1) No(1)
- # Pratian technology interview question
# write code for given series
# 2,3,5,11,23,29,41,53,83...
# this series is called "sophie series"
"""
the series iterate through integers which are prime as well as
its (2n+1) is also prime (where n is current number).
"""
def series(times):
count=1
value=2
while count=2:
return True
times=int(input())
series(times) - 7 years agoHelpfull: Yes(1) No(0)
- import java.util.*;
public class P6 {
public static void main(String[] args) {
System.out.println("Enter the value :");
Scanner read = new Scanner(System.in);
int number = read.nextInt();
for(int i=2;i - 7 years agoHelpfull: Yes(1) No(1)
- int i,j,k,n,m=0,r=0;
for(i=1;i - 6 years agoHelpfull: Yes(1) No(0)
- #include
int main(){
int n,j,i,a,s,m,k;
scanf("%d",&n);
for (i=2; i - 8 years agoHelpfull: Yes(0) No(5)
- package javaapplication1;
import java.util.*;
/**
*
* @author DELL
*/
public class ShopieGermanPrime {
public static boolean check(int i )
{
int count=0;
int m=i;
for(int j=2;j - 8 years agoHelpfull: Yes(0) No(0)
- public class Pratian7 {
public static void main(String[] args) {
int i, num;
for (i = 3; i = 1; num--) {
if (i%num==0 ||(2 + i)% num == 0) {
counter = counter + 1;
}
}
if (counter == 2) {
System.out.print(i+1+" ");
}
}
}
} - 8 years agoHelpfull: Yes(0) No(0)
- public class Series {
public static void main(String args[]){
int a=0,b=0;
for(int i=2;i - 8 years agoHelpfull: Yes(0) No(0)
- class Test1 {
public static void main(String args[]){
Hello h= new Hello();
for( int j=1; j - 7 years agoHelpfull: Yes(0) No(0)
- public class MyClass {
public static int prime(int a){
int count=0;
for(int i=2;i - 7 years agoHelpfull: Yes(0) No(0)
- #include
int isprime(int m);
void main()
{
int i,j,s;
for(i=0;i - 6 years agoHelpfull: Yes(0) No(0)
- #include
#include
bool isP(int n)
{
int i;
if (n - 6 years agoHelpfull: Yes(0) No(0)
- these are the prime numbers
- 6 years agoHelpfull: Yes(0) No(0)
Pratian technologies Other Question
write a program to generate the following series.Accept the limit upto which the series needs to be generated.
1, -2, 6, -15, 31, -56,....N
write a programming logic to generate to the series: 1,1,2,12,14,26,40,264,304,568...