• Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
CODE OF GEEKS

We at CODE OF GEEKS, aim at providing best and quality content for our users at no extra cost.

    • Study Materials – Company wise
      • Infosys Archive
      • Accenture Archive
      • AMCAT Archive
      • Capgemini Archive
      • Cisco Archive
      • CoCubes Archive
      • Cognizant(CTS) Archive
      • Dell Archive
      • Deloitte Archive
      • DXC Archive
      • Goldman Sachs Archive
      • Hexaware Technologies Archive
      • LTI Archive
      • MindTree Archive
      • TCS Archive
      • Virtusa Archive
      • Wipro Archive
    • Interview Preparation – E Books
      • C Interview Questions
      • Data Structures Interview Questions
      • DBMS Interview Questions
      • HR Interview Questions
      • Java Interview Questions
      • Operating System Interview Questions
      • Python Interview Questions
      • SQL Query Interview Questions
    • Programming
      • C Programming MCQs
      • C Code Snippets – Output Questions
      • Python Code Snippets – Output Questions
    • Aptitude
      • Verbal Ability for Placements
      • Quant for Placements
    • Register
    • Login
  • [email protected]
  • ..
Login / Register
Apply Now
CODE OF GEEKS
CODE OF GEEKS
  • Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
0

Cart

Pronic Number

  • January 6, 2020
  • CODE OF GEEKS
  • 3


Given a string of random numbers, your job is to find the product of the numbers(one is lesser and one is greater) who is already present in the string. 

For instance, a pronic number is a number which is the product of two consecutive integers, that is, a number of the form n(n + 1). Like 6 is the pronic number as 2*3 = 6.

Input : 

First Input : String of random numbers

Output : List of pronic numbers



Sample Testcases :

I/P 1:

123456

O/P 1:

[2,6,12]

I/P 2:

4567

O/P 2:

-1

Solution :

import itertools
list1=[]
s=str(input())
res = [s[i: j] for i in range(len(s)) for j in range(i + 1, len(s) + 1)]
def pronic(s1):
    set1=[]
    set2=[]
    for p in range(0,len(s1)-1):
        a=int(s1[p])
        b=int(s1[p+1])
        mul=int(a*b)
        mul=str(mul)
        if mul in res:
            set1.append(mul)
    if (len(set1)==0):
        print(“-1”)
    else:    
        print(set1)
pronic((s)) 


Tags: infosys last year handson problemsinfytqinfytq examinfytq examinationinfytq handson problems last yearinfytq handson problems of last yearinfytq handson questionsinfytq last year problemsinfytq last year questionsLast year questions Infytqpractice infyprepare infytq question
  • Previous Factor Game
  • Next Even Odd Series

3 comments on “Pronic Number”

  1. Anonymous says:
    March 18, 2020 at 12:06 pm

    According to the question number can be selected from anywhere else from the string, but in the solution you selected the adjacent elements and multiply this and check for the multiplication in the string

    but we can select the numbers from anywhere the string so one approch is to sort the numbers and then apply above solution.

    or the question is about to select the adjacent element only? Please guide as we are very confused.

    Reply
    1. Hell says:
      June 13, 2020 at 3:39 pm

      check in geeks for geeks finding sqrt see it once

      Reply
  2. Prince says:
    April 14, 2021 at 3:23 pm

    can you please provide java solution also ?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CODE OF GEEKS

Subscribe to Newsletter

CODE OF GEEKS

Learn | Code | Achieve

Reach us

[email protected]
We at CODE OF GEEKS, aim at providing quality content to our users at no cost.
CODE OF GEEKS

Important Pages

About us
Advertise
Privacy Policy
Terms and Conditions

Placements – Study Materials

TCS NQT     Wipro     CapGemini
Accenture     MindTree     CTS
DXC     Hexaware Technologies     AMCAT
CoCubes     Goldman Sachs     Dell
Cisco     Deloitte     Virtusa     LTI     Infosys   

Courses

  • Mail Us
  • Login/Register

Recent Posts

What is Cloud Computing | Cloud Computing Applications | Cloud Development Models| SaaS vs PaaS vs IaaS
  • October 23, 2021
What is Amazon Web Services | AWS Regions & AZs | Different AWS Services
  • October 19, 2021

Copyright 2021 CODE OF GEEKS. All Rights Reserved.

  • →