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]
4 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]4 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
Hello! I am a new coder, so this is a simple question. But I am trying to create a code where you enter a number, then another n
slavikrds [6]

no longer returns an error but your math seems to have something wrong with it, always returns 0

Console.WriteLine("Enter a percentage here");

   int Percent = int.Parse(Console.ReadLine());

   Console.WriteLine("Enter your number here");

   int Number = int.Parse(Console.ReadLine());

   int result = Percent / 100 * Number;

6 0
3 years ago
Write a Python 3 program that prompts the user for 3 postive numbers (or zero) and then adds them together. If the user enters a
Citrus2011 [14]

Answer:

def prompt_number():

   while True:

       number = int(input("Enter a number: "))

       if number >= 0:

           break

       

   return number

   

def compute_sum(n1, n2, n3):

   total = n1 + n2 + n3

   return total

   

n1 = prompt_number()

n2 = prompt_number()

n3 = prompt_number()

result = compute_sum(n1, n2, n3)

print(result)

Explanation:

Create a function named prompt_number that asks the user to enter a number until a positive number or 0 is entered and returns the number

Create a function named compute_sum that takes three numbers, sums them and returns the sum

Ask the user to enter three numbers, call the prompt_number() three times and assign the values

Calculate the the sum, call the compute_sum and pass the numbers as parameters

Print the result

6 0
3 years ago
You are considering upgrading memory on a laptop. What are three attributes of currently installed memory that HWiNFO can give t
Dennis_Churaev [7]

Answer:

Some of the qualities of the installed memory which HWiNFO can reveal are:

  • Date of manufacture
  • Memory type
  • Speed of memory

Explanation:

HWiNFO is an open-source systems information app/tool which Windows users can utilize as they best wish. It helps to detect information about the make-up of computers especially hardware.

If you used HWiNFO to diagnose the memory, the following information will be called up:

  • the total size of the memory and its current performance settings
  • the size of each module, its manufacturer, and model
  • Date of manufacture
  • Memory type
  • Speed of memory
  • supported burst lengths and module timings,
  • write recovery time etc.

Cheers

6 0
3 years ago
8-16 Value of Dividends and Future Price A firm is expected to pay a dividend of $2.05 next year and $2.35 the following year. F
IgorC [24]

Answer:

$91.40

Explanation:

See attached picture.

3 0
3 years ago
What are some of the best free sources to learn programming?
lilavasa [31]

Answer:

I don't know man. Every time I post any questions about computer science. A guy  keep delete them. I lost so many point for not submitting my homework.

Explanation:

6 0
3 years ago
Other questions:
  • Produce definition in computer
    12·2 answers
  • . Business-to-business integration (B2Bi) is vital for efficient and accurate flow of data across internal ISs and external busi
    11·1 answer
  • PLEASE HELP ME ASP<br> An ISDN carries a signal in digital form.<br><br> True<br><br> False
    12·2 answers
  • 8.5 question 2 edhesive
    11·1 answer
  • Write a program that asks for the weight of a package and the distance it is to be shipped. This information should be passed to
    12·1 answer
  • The photographer for "The Migrant Mother" photograph used _______________, which is a technique that would be considered unethic
    8·2 answers
  • The costs incurred when a firm buys on the marketplace what it cannot make itself are referred to as
    6·1 answer
  • Help PLEASE ILL MARK as brainlest
    11·1 answer
  • What will help the programmer understand what’s going on in the program?
    12·1 answer
  • Cyber vulnerabilities to dod systems may include
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!