File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 11""" 
2+ Problem 28 
3+ Url: https://projecteuler.net/problem=28 
4+ Statement: 
25Starting with the number 1 and moving to the right in a clockwise direction a 5 
36by 5 spiral is formed as follows: 
47
1720from  math  import  ceil 
1821
1922
20- def  diagonal_sum ( n ) :
23+ def  solution ( n :  int   =   1001 )  ->   int :
2124    """Returns the sum of the numbers on the diagonals in a n by n spiral 
2225    formed in the same way. 
2326
24-     >>> diagonal_sum (1001) 
27+     >>> solution (1001) 
2528    669171001 
26-     >>> diagonal_sum (500) 
29+     >>> solution (500) 
2730    82959497 
28-     >>> diagonal_sum (100) 
31+     >>> solution (100) 
2932    651897 
30-     >>> diagonal_sum (50) 
33+     >>> solution (50) 
3134    79697 
32-     >>> diagonal_sum (10) 
35+     >>> solution (10) 
3336    537 
3437    """ 
3538    total  =  1 
@@ -46,10 +49,10 @@ def diagonal_sum(n):
4649    import  sys 
4750
4851    if  len (sys .argv ) ==  1 :
49-         print (diagonal_sum ( 1001 ))
52+         print (solution ( ))
5053    else :
5154        try :
5255            n  =  int (sys .argv [1 ])
53-             print (diagonal_sum (n ))
56+             print (solution (n ))
5457        except  ValueError :
5558            print ("Invalid entry - please enter a number" )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments