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))
@sankalpnaik8778 ай бұрын
Your "smartwork" will take more time than writing logic
@flash_ae9 ай бұрын
package TCS; public class Question1 { private static boolean isPrime(int i) { if(i
@ranadheerpenki99196 ай бұрын
🎯 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
@yashdarole77928 ай бұрын
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
@maheenfatma46943 ай бұрын
Are these actual TCS questions??
@ArnabBhadra02 Жыл бұрын
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
@CodeBashers Жыл бұрын
One will be easy and second will be difficult
@vishurathore16769 ай бұрын
public static boolean isPrime(int n){ for(int i =2 ; i
@shadowfrank17315 ай бұрын
U didn't input the nth term? How will u get the answer
@giveawayfinder_Roni9 ай бұрын
thanks sir previous yr qst solve kariye plz.
@abhishekkumarsingh611 Жыл бұрын
39 is not prime you have put true
@abhishekanand34624 ай бұрын
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 ??
@mechscitech62274 ай бұрын
fixed hota hai dono question ka time slot
@abhishekanand34624 ай бұрын
@@mechscitech6227 Aur , kya 10 hi Compilations milte hai ek Question ke liye ?
@abhishekanand34624 ай бұрын
@@mechscitech6227 kya humlog #include ka use kar sakte hai TCS ke exam me
@Tanmoy-d4h3 ай бұрын
@@abhishekanand3462 nhi
@trusfratedbunny22152 ай бұрын
@@abhishekanand3462 Bro can u plz tell what this header do..?
@saiavinash663Ай бұрын
how to write code in python
@sagarsinha6684 ай бұрын
jise coding ka c nhi ata wo kese kre....kese kia or kese padhe ki yh chije samjh ay
@amitkr36418 ай бұрын
Can you tell me one thing that NQT exam will be MCQ based or not ?
@imvishal_kr8 ай бұрын
All sections will be MCQ, except coding part
@AmberSparrow876 Жыл бұрын
Is this an easy-level question?
@TheRewindRoom8 ай бұрын
Medium level
@servingcynical9822 Жыл бұрын
Provide me in Java
@arun55367 ай бұрын
Python programming
@preetamkumar81285 ай бұрын
Can you give me this coding question as java i can't understand python
@CodeBashers5 ай бұрын
Hi contact me at t.me/cdb15
@terranceraj68348 ай бұрын
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
@AlgorithmCodings5 ай бұрын
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
@trusfratedbunny22152 ай бұрын
What to do, Values at remaining position is not coming When enter that element like values at position 6, 8, 10, 12, 14, 15
@Czjajava8 ай бұрын
16 is a power of 3 ?????
@Standboard8 ай бұрын
16 is a perfect sqaure of 4 which you have to replace with a power of 3
@Ravi_Raj_._09-v5w8 ай бұрын
39 is not a prime number
@harshprajapat1656 ай бұрын
It is prime bro
@prabhakarsinghbaghel39045 ай бұрын
@@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
@03_utpallucky406 ай бұрын
#include #include using namespace std; bool isPrime(int n){ for(int m=2;m
@nagalavanyadoradla607611 ай бұрын
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))
@AJayasri-p3xАй бұрын
How to contact you.
@CodeBashersАй бұрын
Contact me at t.me/cdb15
@dharanirama49148 ай бұрын
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