Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

como fazer em python

+1 vote
asked May 15, 2021 by paulo magalhaes (1,480 points)
O numero 3025 possui a seguinte caracterıstica:

30 + 25 = 55

55elevado2 = 3025

(1) Fazer um algoritmo que dado um numero de 4 dıgitos calcule e escreva se ele possui ou nao esta caracter´ıstica.

1 Answer

0 votes
answered May 17, 2021 by Peter Minarik (86,040 points)

You now the drill. :)

You give your best shot to solve the problem. Then someone from the community can help you out to solve issues you have in the code, if any.

You really should try to solve the assignments first on your own before you ask others to do it for you. ;)

Pointers:

  • Read a string from the input
  • Turn (cast) it into a number
  • Make sure it is 4 digit long.
  • Cut off the first 2 and last 2 digits.
  • check if the sum of these two numbers (first + last parts) to the power of 2 equals the original number
  • Feel free to add optimizations, if you feel like (e.g. if the entered number ends with 2, 3, 7 or 8 then they definitely do not satisfy the rules -- no squares of an integral number can end with these digits -- See here.).

Good luck!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...