import math def isprime(n): c=0 for i in range(2,n): if n%i==0: c+=1 if c==0: return True else: return False def isperfect(n): if n**0.5==int(n**0.5): return True else: return False def out(n): if n==0: print(1) l=[] m=[] for i in range(2,n+1): if isprime(i): l.append(i) for i in range(1,n+1): if isperfect(i): m.append(i) if isprime(n): r=l.index(n) res=int(math.pow(2,r)) return res elif isperfect(n): r=m.index(n) res=int(math.pow(3,r)) return res else: c=out(n-1)+out(n-2) return int(c) n=int(input()) print(out(n))
in java import java.util.*; public class equiindex{ private static HashSet primes = new HashSet(Arrays.asList(2,3,5,7,11,13,17,19,23,29,31,37)); public static Boolean isPrime(int n){ return primes.contains(n); } private static HashSet square = new HashSet(Arrays.asList(1,4,9,16,25,36)); public static Boolean isSquare(int n){ return square.contains(n); } public static void Series(int n ){ int pop=1; int pos=1; int arr[] = new int [n]; for(int i=0;i
🎯 Key points for quick navigation: 01:14 *🧩 Understanding the series pattern with prime and square positions.* 02:51 *📊 Explaining how to derive the series based on prime, square, and other positions.* 07:22 *💡 Approach to solving the coding question by iterating through the series positions.* 11:49 *🖥️ Code walkthrough for implementing the logic of identifying prime numbers, perfect squares, and sum of previous two values.* 17:51 *🔄 Ensuring correct output by adjusting array indexing based on positions in the series.* Made with HARPA AI
Jo 2 Coding Questions ke liye 90 Min milte hai ,usme humlog kabhi bhi unn 2 Questions ke beech switch kar sakte hai ki ?? Har 1 Coding Question ka time slot fixed hota hai aur agar fixed hota hai to 1st quesn ko kitna time milta hai ??
This kind of question is foundation level qs or advance level And one more thing in the advance section the both coding will be tough or one will be easy
package java_pratice; import java.util.*; public class hello { public static void main(String[] args){ Scanner in = new Scanner(System.in); int term = in.nextInt(); int power_of_2 =1; int power_of_3 =1; int[] arr =new int[term]; for(int i=0;i
i had to write this particular piece of code for it to understand the last else condition cuz the array was going out of bounds if (n >= 1) { arr[0] = 1; } if (n >= 2) { arr[1] = 1; } can we do this in some alternate way
Can You please check whether this code works properly for all test cases def powerOf(a,b): if(b==0): return 1 else: return a*powerOf(a,b-1) def prime(n): c=0 for i in range(2,n): if(n%i==0): c=c+1 break if(c==1): return False else: return True def perfect(n): if(n**0.5==int(n**0.5)): return True else: return False def count(n): if(n==0 or n==1): print(1) l=[] l1=[] for i in range(2,n+1): if(prime(i)): l.append(i) for i in range(2,n+1): if(perfect(i)): l1.append(i) if(prime(n)): r=l.index(n) ans=powerOf(2,r) return ans elif(perfect(n)): r2=l1.index(n)+1 ans2=powerOf(3,r2) return ans2 else: return count(n-1)+count(n-2) n=int(input()) print(count(n))
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n=sc.nextInt(); int pos=1; int pos1=1; int a[]=new int[41]; for(int i=1;i
Your "smartwork" will take more time than writing logic
package TCS;
public class Question1 {
private static boolean isPrime(int i) {
if(i
import math
def isprime(n):
c=0
for i in range(2,n):
if n%i==0:
c+=1
if c==0:
return True
else:
return False
def isperfect(n):
if n**0.5==int(n**0.5):
return True
else:
return False
def out(n):
if n==0:
print(1)
l=[]
m=[]
for i in range(2,n+1):
if isprime(i):
l.append(i)
for i in range(1,n+1):
if isperfect(i):
m.append(i)
if isprime(n):
r=l.index(n)
res=int(math.pow(2,r))
return res
elif isperfect(n):
r=m.index(n)
res=int(math.pow(3,r))
return res
else:
c=out(n-1)+out(n-2)
return int(c)
n=int(input())
print(out(n))
Are these actual TCS questions??
in java
import java.util.*;
public class equiindex{
private static HashSet primes = new HashSet(Arrays.asList(2,3,5,7,11,13,17,19,23,29,31,37));
public static Boolean isPrime(int n){
return primes.contains(n);
}
private static HashSet square = new HashSet(Arrays.asList(1,4,9,16,25,36));
public static Boolean isSquare(int n){
return square.contains(n);
}
public static void Series(int n ){
int pop=1;
int pos=1;
int arr[] = new int [n];
for(int i=0;i
🎯 Key points for quick navigation:
01:14 *🧩 Understanding the series pattern with prime and square positions.*
02:51 *📊 Explaining how to derive the series based on prime, square, and other positions.*
07:22 *💡 Approach to solving the coding question by iterating through the series positions.*
11:49 *🖥️ Code walkthrough for implementing the logic of identifying prime numbers, perfect squares, and sum of previous two values.*
17:51 *🔄 Ensuring correct output by adjusting array indexing based on positions in the series.*
Made with HARPA AI
thanks sir
previous yr qst solve kariye plz.
39 is not prime you have put true
public static boolean isPrime(int n){
for(int i =2 ; i
U didn't input the nth term? How will u get the answer
Jo 2 Coding Questions ke liye 90 Min milte hai ,usme humlog kabhi bhi unn 2 Questions ke beech switch kar sakte hai ki ?? Har 1 Coding Question ka time slot fixed hota hai aur agar fixed hota hai to 1st quesn ko kitna time milta hai ??
fixed hota hai dono question ka time slot
@@mechscitech6227 Aur , kya 10 hi Compilations milte hai ek Question ke liye ?
@@mechscitech6227 kya humlog #include ka use kar sakte hai TCS ke exam me
@@abhishekanand3462 nhi
@@abhishekanand3462 Bro can u plz tell what this header do..?
Python programming
jise coding ka c nhi ata wo kese kre....kese kia or kese padhe ki yh chije samjh ay
This kind of question is foundation level qs or advance level
And one more thing in the advance section the both coding will be tough or one will be easy
One will be easy and second will be difficult
how to write code in python
Can you tell me one thing that NQT exam will be MCQ based or not ?
All sections will be MCQ, except coding part
Is this an easy-level question?
Medium level
How to contact you.
Contact me at t.me/cdb15
Provide me in Java
Can you give me this coding question as java i can't understand python
Hi contact me at t.me/cdb15
16 is a power of 3 ?????
16 is a perfect sqaure of 4 which you have to replace with a power of 3
package java_pratice;
import java.util.*;
public class hello {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int term = in.nextInt();
int power_of_2 =1;
int power_of_3 =1;
int[] arr =new int[term];
for(int i=0;i
What to do, Values at remaining position is not coming When enter that element like values at position 6, 8, 10, 12, 14, 15
i had to write this particular piece of code for it to understand the last else condition cuz the array was going out of bounds
if (n >= 1) {
arr[0] = 1;
}
if (n >= 2) {
arr[1] = 1;
}
can we do this in some alternate way
39 is not a prime number
It is prime bro
@@harshprajapat165 13x3=39 how is it prime dude, basic maths 3+9=12 which means its divisible by 3 as 12 is divisible by 3
Can You please check whether this code works properly for all test cases
def powerOf(a,b):
if(b==0):
return 1
else:
return a*powerOf(a,b-1)
def prime(n):
c=0
for i in range(2,n):
if(n%i==0):
c=c+1
break
if(c==1):
return False
else:
return True
def perfect(n):
if(n**0.5==int(n**0.5)):
return True
else:
return False
def count(n):
if(n==0 or n==1):
print(1)
l=[]
l1=[]
for i in range(2,n+1):
if(prime(i)):
l.append(i)
for i in range(2,n+1):
if(perfect(i)):
l1.append(i)
if(prime(n)):
r=l.index(n)
ans=powerOf(2,r)
return ans
elif(perfect(n)):
r2=l1.index(n)+1
ans2=powerOf(3,r2)
return ans2
else:
return count(n-1)+count(n-2)
n=int(input())
print(count(n))
#include
#include
using namespace std;
bool isPrime(int n){
for(int m=2;m
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int pos=1;
int pos1=1;
int a[]=new int[41];
for(int i=1;i
39 is not a prime no
Can u contact me at t.me/cdb15
39 is not a prime number
39 is not a prime number