CONJETURE COLLATZ

Status
Not open for further replies.

ZLOSADA

New Member
Joined
Apr 4, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
buenas noches,

Requiero ayuda para crear una función en VBA que contenga
Una función llamada “CollatzMaxTotal” que dio un número:

Si el número no es un entero positivo genere un texto que diga: “El número no es entero positivo” , pero si es un número entero positivo, genere un texto que diga el máximo valor que alcanzo el número con la conjetura de Collatz y la cantidad de pasos que necesita para llegar por primera vez al número 1. Ejm:

Si el número es 7 entonces la función genera: El máximo valor fue de 52 y para llegar a 1 necesita 16 pasos .

Si el número es 9,2 entonces la función genera: El número no es entero positivo

Si el número es 35 entonces la función genera: El máximo valor fue de 160 y para llegar a 1 necesita 13 pasos .

La agradezco la ayuda, soy nueva y poco entiendo, he hecho esto:

Función Z(i) como cadena




Si i.Valor <> Int(i.Valor) Entonces


Z = "El numero no es entero positivo"

Demás

Z = "máximo valor que alcanzó el número con la conjetura de Collatz"

Terminara si




función final
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
jplease post in English.
Create a function called "CollatzMaxTotal" that given a number:
If the number is not a positive integer, generate a text that says: "The number is not a positive integer", but if it is a positive integer, generate a text that says the maximum value that the number reached with the Collatz conjecture and the number of steps it takes to get to number 1 for the first time. Example:
If the number is 7 then the function outputs: The maximum value was 52 and to get to 1 it takes 16 steps.
If the number is 9.2 then the function outputs: The number is not a positive integer
If the number is 35 then the function outputs: The maximum value was 160 and it takes 13 steps to get to 1.
Thank you
 
Upvote 0
basically says: Pick any natural number n. If n is even, take n and divide by 2. If n is odd, multiply n by 3 and add 1. Repeat this algorithm and regardless of what number you picked to begin with, you will always end at 1
 
Upvote 0
Duplicate to: CODE CONJETURE COLLATZ

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,829
Messages
6,181,222
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top