7 kyu

Simple Fun #113: Number Increasing

111 of 370myjinxin2015

Description:

Task

Initially a number 1 is written on a board. It is possible to do the following operations with it:

multiply the number by 3; increase the number by 5. Your task is to determine that using this two operations step by step, is it possible to obtain number n?

Example

For n = 1, the result should be true.

1 = 1

For n = 2, the result should be false.

For n = 3, the result should be true.

1 x 3 = 3

For n = 4, the result should be false.

For n = 5, the result should be false.

For n = 6, the result should be true.

1 + 5 = 6

For n = 18, the result should be true.

1 + 5 = 6 --> 6 x 3 = 18

For n = 32, the result should be true.

1 x 3 x 3 x 3 = 27 --> 27 + 5 = 32

For n = 100, the result should be false.

For n = 101, the result should be true.

1 + 5 + 5 + 5 ... +5 = 101

Input / Output

  • [input] integer n

positive integer, n ≤ 100000

  • [output] a boolean value

true if N can be obtained using given operations, false otherwise.

Puzzles

Stats:

CreatedFeb 10, 2017
PublishedFeb 10, 2017
Warriors Trained1310
Total Skips18
Total Code Submissions2542
Total Times Completed370
JavaScript Completions111
C# Completions56
Python Completions217
Ruby Completions30
Total Stars23
% of votes with a positive feedback rating84% of 119
Total "Very Satisfied" Votes87
Total "Somewhat Satisfied" Votes26
Total "Not Satisfied" Votes6
Total Rank Assessments6
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • smile67 Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • mauro-1 Avatar
Ad