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

Home > Numbers
The final quantity (Posted on 2015-02-18) Difficulty: 2 of 5
Given a list of all composite numbers below 1000, how many will remain after erasure of numbers divisible by 2,3 or 5?

Rem1: "or" is inclusive i.e. and/or.
Rem2: number 1 is neither prime nor composite, so it does not appear on the initial list.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 4
There are 100:

49 77 91 119 121 133 143 161 169 187 203 209 217 221 247 253 259 287 289 299 301 319 323 329 341 343 361 371 377 391 403 407 413 427 437 451 469 473 481 493 497 511 517 527 529 533 539 551 553 559 581 583 589 611 623 629 637 649 667 671 679 689 697 703 707 713 721 731 737 749 763 767 779 781 791 793 799 803 817 833 841 847 851 869 871 889 893 899 901 913 917 923 931 943 949 959 961 973 979 989

100



DefDbl A-Z
Dim wd(10) As String, w As String, sz, crlf$
Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 
 For n = 2 To 1000
   If prmdiv(n) < n Then
     If n Mod 2 > 0 And n Mod 3 > 0 And n Mod 5 > 0 Then
       Text1.Text = Text1.Text & Str(n)
       DoEvents
       ct = ct + 1
     End If
   End If
 Next
 Text1.Text = Text1.Text & crlf & crlf & ct
 
 End Sub
Function prm(i)
  Dim p As Long
  Open "17-bit primes.bin" For Random As #111 Len = 4
  Get #111, i, p
  prm = p
  Close 111
End Function
Function prmdiv(num)
 Dim n, dv, q
 If num = 1 Then prmdiv = 1: Exit Function
 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
 Loop
 If n > 1 Then prmdiv = n
 Exit Function

DivideIt:
 Do
  q = Int(n / dv)
  If q * dv = n And n > 0 Then
    prmdiv = dv: Exit Function
   Else
    Exit Do
  End If
 Loop

 Return
End Function
Function nxtprm(x)
  Dim n
  n = x + 1
  While prmdiv(n) < n
    n = n + 1
  Wend
  nxtprm = n
End Function


  Posted by Charlie on 2015-02-18 10:27:51
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 (3)
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