All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
A frugal sequence (Posted on 2012-09-14) Difficulty: 3 of 5
Find the longest(?) string of consecutive frugal numbers.

Def: A frugal number is a natural number that has more digits than the number of digits in its prime factorization (including exponents). For example, 128=2^7 and 29282=2*11^4

See The Solution Submitted by Ady TZIDON    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts computer results so far | Comment 6 of 13 |

DECLARE SUB factor (num#, s$)
DECLARE FUNCTION frugal# (x#)
DEFDBL A-Z
CLS
ct = 0
FOR i = 1 TO 22000000
 IF frugal(i) THEN
   IF ct = 0 THEN
     ct = 1
     firstno = i
   ELSE
     ct = ct + 1
   END IF
 ELSE
   IF ct > max THEN
     max = ct
     maxfirstno = firstno
     PRINT maxfirstno, max
   END IF
   ct = 0
 END IF
NEXT

SUB factor (num, s$)
 s$ = "": n = ABS(num): IF n > 0 THEN limit = SQR(n):  ELSE limit = 0
 IF limit <> INT(limit) THEN limit = INT(limit + 1)
 dv = 2: GOSUB DivideIt
 dv = 3: GOSUB DivideIt
 dv = 5: GOSUB DivideIt
 dv = 7
 DO UNTIL dv > limit
   GOSUB DivideIt: dv = dv + 4 '11
   GOSUB DivideIt: dv = dv + 2 '13
   GOSUB DivideIt: dv = dv + 4 '17
   GOSUB DivideIt: dv = dv + 2 '19
   GOSUB DivideIt: dv = dv + 4 '23
   GOSUB DivideIt: dv = dv + 6 '29
   GOSUB DivideIt: dv = dv + 2 '31
   GOSUB DivideIt: dv = dv + 6 '37
   IF INKEY$ = CHR$(27) THEN s$ = CHR$(27): EXIT SUB
 LOOP
 IF n > 1 THEN s$ = s$ + LTRIM$(STR$(n))
 EXIT SUB

DivideIt:
 count = 0
 DO
  q = INT(n / dv)
  IF q * dv = n AND n > 0 THEN
    n = q: count = count + 1: IF n > 0 THEN limit = SQR(n):  ELSE limit = 0
    IF limit <> INT(limit) THEN limit = INT(limit + 1)
   ELSE
    EXIT DO
  END IF
 LOOP
 IF count > 0 THEN
   s$ = s$ + LTRIM$(STR$(dv))
   IF count > 1 THEN s$ = s$ + LTRIM$(STR$(count))
 END IF
 RETURN
END SUB

FUNCTION frugal (x)
  factor x, s$
  IF LEN(s$) < LEN(LTRIM$(STR$(x))) THEN frugal = 1:  ELSE frugal = 0
END FUNCTION

Finds that a sequence of two consecutive frugal numbers begins at 4374, and three consecutive frugal numbers begin at 1097873:

1097873 = 7*47^3*71
1097874 = 2*3^7*251
1097875 = 5^3*8783


  Posted by Charlie on 2012-09-14 15:59:58
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information