1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
docker41 [41]
3 years ago
10

Find every number from 1 to n (inclusive) that is a palindrome which starts with the digit 3. Do not user a helper function.

Computers and Technology
1 answer:
Mkey [24]3 years ago
7 0

Answer: Following code is in python

n=input()

num='1'

while int(num)<=int(n):    //loop from 1 to n

   flag=1   //if an unequal element will be found it will be 0

   l=len(num)

   if num[0]=='3':

       j=0

       k=l-1

       while j<k:    //loop till middle of number

           if num[j]==num[k]:

               j+=1     //from beginning

               k-=1    //from end

           else:

               flag=0

               break

       if flag==1:

           print(int(num))

   num=str(int(num)+1)    //number will be incremented as integer

INPUT :

1000

OUTPUT :

3

33

303

313

323

333

343

353

363

373

383

393

Explanation:

In the above code, a loop is executed till num is equal to n which is entered by the user. num is treated as a string so that to ease the process of checking first character is 3 or not. If it is 3 then another loop executes which checks if an element from starting is equal to the corresponding element from the end. If an element is not equal then the flag is changed and then we break out of the loop and prints the number if the flag isn't changed.

You might be interested in
Natalie wants to create a database to collect information about sales transactions. She would like to use the database to look u
Lynna [10]

Answer:

Customer Table

  1. Customer name
  2. Customer id

Product Table

  1. Product id/number (primary key, auto increment)
  2. Product name
  3. Product sale price

Transactions Table

  1. Transaction Id
  2. Customer Id
  3. Product id
  4. Quantity
  5. Price
  6. Date

Explanation:

Natalie wants to fetch following information from database

  1. Look up customer name and sale price
  2. Sort items in db by product number

To lookup customer name and sale price perform a join on Transactions table and Customer table.Assuming database is build in mysql the query to fetch required results would be

select transction.productId,transaction.customerid,customer.customername from transactions join customer ON

customer.customerid=transcation.customerid

where productid="user provided product id of returned product"

For sorting products by number set produc number in product table a auto increment primary key

7 0
3 years ago
How to make a water bottle rocket??
k0ka [10]
This question should be in physics so this is my answer in C&T format-go to a online shop and order one or the pieces then follow the instructions that will be given.
6 0
3 years ago
HURRY PLEASE ITS A TEST
laiz [17]

<em>A.)</em>

<em>It's either A or D both of them stand out and make sense to me so I think that it'll be right if you choose A or D.</em>

<em>-Ɽ3₮Ɽ0 Ⱬ3Ɽ0</em>

8 0
3 years ago
In javascript, what can I put after player. to make my character go in the center of the screen? like example:
melamori03 [73]

Answer:

0,0

Explanation:

you could try to use the x-axis and y-axis to put your character in a certain place. I'm not totally sure if that is how javascript works, but for the x-axis and y-axis, the center is always(0,0).

6 0
3 years ago
1.
aliya0001 [1]
#1 is D #2 is B #3 is A #4 is D #5 is B
3 0
2 years ago
Read 2 more answers
Other questions:
  • PLEASE HURRY What data unit is addressed based on the IP address of the recipient? a. packet b. frame c. segment d. section
    9·2 answers
  • Which key removes all data from an active cell with one click? A. Esc B. Delete C. Tab D. F2
    9·2 answers
  • ____________ hackers break into systems legally for non-malicious reasons such as to test system security vulnerabilities
    7·2 answers
  • To create a chart, you need to select at least
    8·1 answer
  • Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(l
    5·1 answer
  • To date, what has most propelled the digital revolution?
    10·1 answer
  • Justice wrote a program and forgot to put the steps in the correct order. Which step does she need to review?
    5·2 answers
  • Which of the following was most likely used to apply red background and font to some of the cells in column D?
    10·1 answer
  • Write 2 paragraphs. 1 comparing Shrek the movie and Shrek the musical and another contrasting them.
    12·2 answers
  • In PowerPoint, a picture might be a photograph, a shape you draw, a piece of clip art, or an illustration created using a graphi
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!