How to find the pair of divisors which are closest in value for a non-prime number? If prime, how to do this for the next largest non-prime?
Mostrar comentarios más antiguos
Case 1: I would like to find the largest two divsors, 'a' and 'b', of a non-prime integer, N such that N = a*b. For instance if N=24, I would like to a code that finds [a,b]=[4,6] not [a,b] = [2,12] etc.
Case 2: If N is prime, say N=11, how do I do this for the next non-prime number? so N=11->N=12 and [a,b] = [3,4].
(For context, I have a loop that generates a number of traces to be plotted where the value N is not known ahead of time. Sometimes N=3 and sometimes N=23. I'm trying to arrange the plots with subplot in a mostly 'square' arrangement that isn't just a skinny column or a skinny row. ).
2 comentarios
David Goodmanson
el 24 de Abr. de 2021
Hi Travis,
for n=14 for example, will 2x7 (which fits the rule) be all right, or would 3x5 be better? for n = 22 would 2x11 be all right, or would 4x6 be better?
Travis Briles
el 24 de Abr. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!