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

Home > Numbers
Hi there, Pascal (Posted on 2014-09-01) Difficulty: 2 of 5
How many odd entries are there in the 2014th row of Pascal's Triangle?


Rem: Please compare with my "Bonjour, Pascal!" of April 2014 .

See The Solution 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 2
DefDbl A-Z
Dim crlf$, row(1, 3000)


Private Sub Form_Load()
 ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 row(1, 1) = 1: row(1, 2) = 1
 For n = 2 To 2014
   For i = 1 To n
     row(0, i) = row(1, i)
   Next
   totodd = 0
   For i = 1 To n + 1
     row(1, i) = (row(0, i) + row(0, i - 1)) Mod 2
     
     If row(1, i) Then totodd = totodd + 1
   Next
   Text1.Text = Text1.Text & Str(n) & Str(totodd) & crlf
   DoEvents
 Next


 Text1.Text = Text1.Text & crlf & " done"
End Sub



The first few rows show the following counts:

  2 2 (1 2 1)
  3 4 (1 3 3 1)
  4 2 etc.
  5 4
  6 4
  7 8
  8 2
  9 4
 10 4
 11 8
 12 4
 13 8
 14 8
 15 16
 16 2
 17 4
 18 4
 19 8
 20 4
 21 8
 22 8
 23 16
 24 4
 25 8
 26 8
 27 16
 28 8
 29 16
 30 16
 31 32
 32 2
 33 4
 34 4
 35 8
 36 4
 37 8
 38 8
 39 16
 40 4
 41 8
 42 8
 
Then at the end:
 
  2001 128
  2002 128
  2003 256
  2004 128
  2005 256
  2006 256
  2007 512
  2008 128
  2009 256
  2010 256
  2011 512
  2012 256
  2013 512
  2014 512
 
 
So the 2014th row has 512 odd numbers. 

Also, BTW, one does see the pattern for Bonjour, Pascal.


  Posted by Charlie on 2014-09-01 12:36: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 (8)
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